Step 1 of rewriting Alchemy - Removing all the old code

This commit is contained in:
nossr50
2019-05-12 00:53:15 -07:00
parent ddb92af400
commit 1c6b0363ce
26 changed files with 1856 additions and 1897 deletions

View File

@ -0,0 +1,38 @@
//package com.gmail.nossr50.runnables.skills;
//
//import com.gmail.nossr50.skills.alchemy.Alchemy;
//import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
//import org.bukkit.Location;
//import org.bukkit.block.BrewingStand;
//import org.bukkit.entity.Player;
//import org.bukkit.inventory.ItemStack;
//import org.bukkit.scheduler.BukkitRunnable;
//
//import java.util.Arrays;
//
//public class AlchemyBrewCheckTask extends BukkitRunnable {
// private Player player;
// private BrewingStand brewingStand;
// private ItemStack[] oldInventory;
//
// public AlchemyBrewCheckTask(Player player, BrewingStand brewingStand) {
// this.player = player;
// this.brewingStand = brewingStand;
// this.oldInventory = Arrays.copyOfRange(brewingStand.getInventory().getContents(), 0, 4);
// }
//
// @Override
// public void run() {
// Location location = brewingStand.getLocation();
// ItemStack[] newInventory = Arrays.copyOfRange(brewingStand.getInventory().getContents(), 0, 4);
// boolean validBrew = brewingStand.getFuelLevel() > 0 && AlchemyPotionBrewer.isValidBrew(player, newInventory);
//
// if (Alchemy.brewingStandMap.containsKey(location)) {
// if (oldInventory[Alchemy.INGREDIENT_SLOT] == null || newInventory[Alchemy.INGREDIENT_SLOT] == null || !oldInventory[Alchemy.INGREDIENT_SLOT].isSimilar(newInventory[Alchemy.INGREDIENT_SLOT]) || !validBrew) {
// Alchemy.brewingStandMap.get(location).cancelBrew();
// }
// } else if (validBrew) {
// Alchemy.brewingStandMap.put(location, new AlchemyBrewTask(brewingStand, player));
// }
// }
//}

View File

@ -0,0 +1,118 @@
//package com.gmail.nossr50.runnables.skills;
//
//import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
//import com.gmail.nossr50.datatypes.skills.SubSkillType;
//import com.gmail.nossr50.events.skills.alchemy.McMMOPlayerBrewEvent;
//import com.gmail.nossr50.events.skills.alchemy.McMMOPlayerCatalysisEvent;
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.skills.alchemy.Alchemy;
//import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
//import com.gmail.nossr50.util.Misc;
//import com.gmail.nossr50.util.Permissions;
//import com.gmail.nossr50.util.player.UserManager;
//import org.bukkit.Location;
//import org.bukkit.Material;
//import org.bukkit.block.BlockState;
//import org.bukkit.block.BrewingStand;
//import org.bukkit.entity.Player;
//import org.bukkit.scheduler.BukkitRunnable;
//
//public class AlchemyBrewTask extends BukkitRunnable {
//
// private BlockState brewingStand;
// private Location location;
// private double brewSpeed;
// private double brewTimer;
// private Player player;
// private int fuel;
// private boolean firstRun = true;
//
// public AlchemyBrewTask(BlockState brewingStand, Player player) {
// this.brewingStand = brewingStand;
// this.location = brewingStand.getLocation();
// this.player = player;
//
// brewSpeed = 1.0;
// brewTimer = 400;
//
// if (player != null
// && !Misc.isNPCEntity(player)
// && Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CATALYSIS)
// && UserManager.getPlayer(player) != null) {
//
// double catalysis = UserManager.getPlayer(player).getAlchemyManager().calculateBrewSpeed(Permissions.lucky(player, PrimarySkillType.ALCHEMY));
//
// McMMOPlayerCatalysisEvent event = new McMMOPlayerCatalysisEvent(player, catalysis);
// mcMMO.p.getServer().getPluginManager().callEvent(event);
//
// if (!event.isCancelled()) {
// brewSpeed = catalysis;
// }
// }
//
// if (Alchemy.brewingStandMap.containsKey(location)) {
// Alchemy.brewingStandMap.get(location).cancel();
// }
//
// fuel = ((BrewingStand) brewingStand).getFuelLevel();
//
// if (((BrewingStand) brewingStand).getBrewingTime() == -1) // Only decrement on our end if it isn't a vanilla ingredient.
// fuel--;
//
// Alchemy.brewingStandMap.put(location, this);
// this.runTaskTimer(mcMMO.p, 1, 1);
// }
//
// @Override
// public void run() {
// if (player == null || !player.isValid() || brewingStand == null || brewingStand.getType() != Material.BREWING_STAND || !AlchemyPotionBrewer.isValidIngredient(player, ((BrewingStand) brewingStand).getInventory().getContents()[Alchemy.INGREDIENT_SLOT])) {
// if (Alchemy.brewingStandMap.containsKey(location)) {
// Alchemy.brewingStandMap.remove(location);
// }
//
// this.cancel();
//
// return;
// }
//
// if (firstRun) {
// firstRun = false;
// ((BrewingStand) brewingStand).setFuelLevel(fuel);
// }
//
// brewTimer -= brewSpeed;
//
// // Vanilla potion brewing completes when BrewingTime == 1
// if (brewTimer < Math.max(brewSpeed, 2)) {
// this.cancel();
// finish();
// } else {
// ((BrewingStand) brewingStand).setBrewingTime((int) brewTimer);
// }
// }
//
// private void finish() {
// McMMOPlayerBrewEvent event = new McMMOPlayerBrewEvent(player, brewingStand);
// mcMMO.p.getServer().getPluginManager().callEvent(event);
//
// if (!event.isCancelled()) {
// AlchemyPotionBrewer.finishBrewing(brewingStand, player, false);
// }
//
// Alchemy.brewingStandMap.remove(location);
// }
//
// public void finishImmediately() {
// this.cancel();
//
// AlchemyPotionBrewer.finishBrewing(brewingStand, player, true);
// Alchemy.brewingStandMap.remove(location);
// }
//
// public void cancelBrew() {
// this.cancel();
//
// ((BrewingStand) brewingStand).setBrewingTime(-1);
// Alchemy.brewingStandMap.remove(location);
// }
//}

View File

@ -0,0 +1,167 @@
//package com.gmail.nossr50.datatypes.skills.alchemy;
//
//import com.gmail.nossr50.config.PotionManager;
//import org.bukkit.Color;
//import org.bukkit.Material;
//import org.bukkit.inventory.ItemStack;
//import org.bukkit.inventory.meta.PotionMeta;
//import org.bukkit.potion.Potion;
//import org.bukkit.potion.PotionData;
//import org.bukkit.potion.PotionEffect;
//
//import java.util.List;
//import java.util.Map;
//import java.util.Map.Entry;
//
//public class AlchemyPotion {
// private Material material;
// private PotionData data;
// private String name;
// private List<String> lore;
// private List<PotionEffect> effects;
// private Color color;
// private Map<ItemStack, String> children;
//
// public AlchemyPotion(Material material, PotionData data, String name, List<String> lore, List<PotionEffect> effects, Color color, Map<ItemStack, String> children) {
// this.material = material;
// this.data = data;
// this.lore = lore;
// this.name = name;
// this.effects = effects;
// this.children = children;
// this.color = color;
// }
//
// public String toString() {
// return "AlchemyPotion{" + data + ", " + name + ", Effects[" + effects.size() + "], Children[" + children.size() + "]}";
// }
//
// public ItemStack toItemStack(int amount) {
// ItemStack potion = new ItemStack(material, amount);
// PotionMeta meta = (PotionMeta) potion.getItemMeta();
//
// meta.setBasePotionData(data);
// if (this.getName() != null) {
// meta.setDisplayName(this.getName());
// }
//
// if (this.getLore() != null && !this.getLore().isEmpty()) {
// meta.setLore(this.getLore());
// }
//
// if (!this.getEffects().isEmpty()) {
// for (PotionEffect effect : this.getEffects()) {
// meta.addCustomEffect(effect, true);
// }
// }
//
// if (this.getColor() != null) {
// meta.setColor(this.getColor());
// }
//
// potion.setItemMeta(meta);
// return potion;
// }
//
// public Material getMaterial() {
// return material;
// }
//
// public Potion toPotion(int amount) {
// return Potion.fromItemStack(this.toItemStack(amount));
// }
//
// public PotionData getData() {
// return data;
// }
//
// public void setData(PotionData data) {
// this.data = data;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<String> getLore() {
// return lore;
// }
//
// public void setLore(List<String> lore) {
// this.lore = lore;
// }
//
// public List<PotionEffect> getEffects() {
// return effects;
// }
//
// public void setEffects(List<PotionEffect> effects) {
// this.effects = effects;
// }
//
// public Color getColor() {
// return color;
// }
//
// public void setColor(Color color) {
// this.color = color;
// }
//
// public Map<ItemStack, String> getChildren() {
// return children;
// }
//
// public void setChildren(Map<ItemStack, String> children) {
// this.children = children;
// }
//
// public AlchemyPotion getChild(ItemStack ingredient) {
// if (!children.isEmpty()) {
// for (Entry<ItemStack, String> child : children.entrySet()) {
// if (ingredient.isSimilar(child.getKey())) {
// return PotionManager.getInstance().getPotion(child.getValue());
// }
// }
// }
// return null;
// }
//
// public boolean isSimilar(ItemStack item) {
// if (item.getType() != material) {
// return false;
// }
// if (!item.hasItemMeta()) {
// return false;
// }
// PotionMeta meta = (PotionMeta) item.getItemMeta();
// PotionData that = meta.getBasePotionData();
// if (data.getType() != that.getType()) {
// return false;
// }
// if (data.isExtended() != that.isExtended()) {
// return false;
// }
// if (data.isUpgraded() != that.isUpgraded()) {
// return false;
// }
// for (PotionEffect effect : effects) {
// if (!meta.hasCustomEffect(effect.getType())) {
// return false;
// }
// }
// if (!meta.hasLore() && !lore.isEmpty()) {
// return false;
// }
// if (!(lore.isEmpty() && !meta.hasLore()) && !meta.getLore().equals(lore)) {
// return false;
// }
// if (!meta.hasDisplayName() && name != null) {
// return false;
// }
// return (name == null && !meta.hasDisplayName()) || meta.getDisplayName().equals(name);
// }
//}

View File

@ -0,0 +1,251 @@
//package com.gmail.nossr50.skills.alchemy;
//
//import com.gmail.nossr50.config.PotionManager;
//import com.gmail.nossr50.datatypes.skills.SubSkillType;
//import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
//import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
//import com.gmail.nossr50.events.fake.FakeBrewEvent;
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
//import com.gmail.nossr50.runnables.skills.AlchemyBrewCheckTask;
//import com.gmail.nossr50.util.Permissions;
//import com.gmail.nossr50.util.player.UserManager;
//import org.bukkit.Material;
//import org.bukkit.block.BlockState;
//import org.bukkit.block.BrewingStand;
//import org.bukkit.entity.HumanEntity;
//import org.bukkit.entity.Player;
//import org.bukkit.event.inventory.ClickType;
//import org.bukkit.inventory.BrewerInventory;
//import org.bukkit.inventory.Inventory;
//import org.bukkit.inventory.InventoryView;
//import org.bukkit.inventory.ItemStack;
//
//import java.util.ArrayList;
//import java.util.List;
//
//public final class AlchemyPotionBrewer {
// public static boolean isValidBrew(Player player, ItemStack[] contents) {
// if (!isValidIngredient(player, contents[Alchemy.INGREDIENT_SLOT])) {
// return false;
// }
//
// for (int i = 0; i < 3; i++) {
// if (contents[i] == null || contents[i].getType() != Material.POTION && contents[i].getType() != Material.SPLASH_POTION && contents[i].getType() != Material.LINGERING_POTION) {
// continue;
// }
//
// if (getChildPotion(PotionManager.getInstance().getPotion(contents[i]), contents[Alchemy.INGREDIENT_SLOT]) != null) {
// return true;
// }
// }
//
// return false;
// }
//
// private static AlchemyPotion getChildPotion(AlchemyPotion potion, ItemStack ingredient) {
// if (potion != null) {
// return potion.getChild(ingredient);
// }
//
// return null;
// }
//
// public static boolean isEmpty(ItemStack item) {
// return item == null || item.getType() == Material.AIR || item.getAmount() == 0;
// }
//
// private static void removeIngredient(BrewerInventory inventory, Player player) {
// ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
//
// if (isEmpty(ingredient) || !isValidIngredient(player, ingredient)) {
// } else if (ingredient.getAmount() <= 1) {
// inventory.setIngredient(null);
// } else {
// ingredient.setAmount(ingredient.getAmount() - 1);
// inventory.setIngredient(ingredient);
// }
// }
//
// private static boolean hasIngredient(BrewerInventory inventory, Player player) {
// ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
//
// return !isEmpty(ingredient) && isValidIngredient(player, ingredient);
// }
//
// public static boolean isValidIngredient(Player player, ItemStack item) {
// if (isEmpty(item)) {
// return false;
// }
//
// for (ItemStack ingredient : getValidIngredients(player)) {
// if (item.isSimilar(ingredient)) {
// return true;
// }
// }
//
// return false;
// }
//
// private static List<ItemStack> getValidIngredients(Player player) {
// if (player == null || UserManager.getPlayer(player) == null) {
// return PotionManager.getInstance().getIngredients(1);
// }
//
// return PotionManager.getInstance().getIngredients(!Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier());
// }
//
// public static void finishBrewing(BlockState brewingStand, Player player, boolean forced) {
// if (!(brewingStand instanceof BrewingStand)) {
// return;
// }
//
// BrewerInventory inventory = ((BrewingStand) brewingStand).getInventory();
// ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
//
// if (!hasIngredient(inventory, player)) {
// return;
// }
//
// List<AlchemyPotion> inputList = new ArrayList<>();
//
// for (int i = 0; i < 3; i++) {
// ItemStack item = inventory.getItem(i);
//
// if (isEmpty(item) || item.getType() == Material.GLASS_BOTTLE || !mcMMO.getConfigManager().getPotionManager().isValidPotion(item)) {
// continue;
// }
//
// AlchemyPotion input = mcMMO.getConfigManager().getPotionManager().getPotion(item);
// AlchemyPotion output = input.getChild(ingredient);
//
// inputList.add(input);
//
// if (output != null) {
// inventory.setItem(i, output.toItemStack(item.getAmount()).clone());
// }
// }
//
// FakeBrewEvent event = new FakeBrewEvent(brewingStand.getBlock(), inventory, ((BrewingStand) brewingStand).getFuelLevel());
// mcMMO.p.getServer().getPluginManager().callEvent(event);
//
// if (event.isCancelled() || inputList.isEmpty()) {
// return;
// }
//
// removeIngredient(inventory, player);
//
// for (AlchemyPotion input : inputList) {
// AlchemyPotion output = input.getChild(ingredient);
//
// if (output != null && player != null) {
// PotionStage potionStage = PotionStage.getPotionStage(input, output);
//
// //TODO: hmm
// if (UserManager.hasPlayerDataKey(player)) {
// UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(potionStage, 1);
// }
// }
// }
//
// if (!forced) {
// scheduleUpdate(inventory);
// }
// }
//
// public static boolean transferItems(InventoryView view, int fromSlot, ClickType click) {
// boolean success = false;
//
// if (click.isLeftClick()) {
// success = transferItems(view, fromSlot);
// } else if (click.isRightClick()) {
// success = transferOneItem(view, fromSlot);
// }
//
// return success;
// }
//
// private static boolean transferOneItem(InventoryView view, int fromSlot) {
// ItemStack from = view.getItem(fromSlot).clone();
// ItemStack to = view.getItem(Alchemy.INGREDIENT_SLOT).clone();
//
// if (isEmpty(from)) {
// return false;
// }
//
// boolean emptyTo = isEmpty(to);
// int fromAmount = from.getAmount();
//
// if (!emptyTo && fromAmount >= from.getType().getMaxStackSize()) {
// return false;
// } else if (emptyTo || from.isSimilar(to)) {
// if (emptyTo) {
// to = from.clone();
// to.setAmount(1);
// } else {
// to.setAmount(to.getAmount() + 1);
// }
//
// from.setAmount(fromAmount - 1);
// view.setItem(Alchemy.INGREDIENT_SLOT, to);
// view.setItem(fromSlot, from);
//
// return true;
// }
//
// return false;
// }
//
// /**
// * Transfer items between two ItemStacks, returning the leftover status
// */
// private static boolean transferItems(InventoryView view, int fromSlot) {
// ItemStack from = view.getItem(fromSlot).clone();
// ItemStack to = view.getItem(Alchemy.INGREDIENT_SLOT).clone();
//
// if (isEmpty(from)) {
// return false;
// } else if (isEmpty(to)) {
// view.setItem(Alchemy.INGREDIENT_SLOT, from);
// view.setItem(fromSlot, null);
//
// return true;
// } else if (from.isSimilar(to)) {
// int fromAmount = from.getAmount();
// int toAmount = to.getAmount();
// int maxSize = to.getType().getMaxStackSize();
//
// if (fromAmount + toAmount > maxSize) {
// int left = fromAmount + toAmount - maxSize;
//
// to.setAmount(maxSize);
// view.setItem(Alchemy.INGREDIENT_SLOT, to);
//
// from.setAmount(left);
// view.setItem(fromSlot, from);
//
// return true;
// }
//
// to.setAmount(fromAmount + toAmount);
// view.setItem(fromSlot, null);
// view.setItem(Alchemy.INGREDIENT_SLOT, to);
//
// return true;
// }
//
// return false;
// }
//
// public static void scheduleCheck(Player player, BrewingStand brewingStand) {
// new AlchemyBrewCheckTask(player, brewingStand).runTask(mcMMO.p);
// }
//
// public static void scheduleUpdate(Inventory inventory) {
// for (HumanEntity humanEntity : inventory.getViewers()) {
// if (humanEntity instanceof Player) {
// new PlayerUpdateInventoryTask((Player) humanEntity).runTask(mcMMO.p);
// }
// }
// }
//}

View File

@ -0,0 +1,23 @@
//package com.gmail.nossr50.runnables;
//
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.runnables.skills.AprilTask;
//import com.gmail.nossr50.util.Misc;
//import org.bukkit.scheduler.BukkitRunnable;
//
//public class CheckDateTask extends BukkitRunnable {
//
// @Override
// public void run() {
// if (!mcMMO.getHolidayManager().isAprilFirst()) {
// return;
// }
//
// // Set up jokes
// new AprilTask().runTaskTimer(mcMMO.p, 1L * 60L * Misc.TICK_CONVERSION_FACTOR, 10L * 60L * Misc.TICK_CONVERSION_FACTOR);
// mcMMO.getHolidayManager().registerAprilCommand();
//
// // Jokes deployed.
// this.cancel();
// }
//}

View File

@ -0,0 +1,383 @@
//package com.gmail.nossr50.util;
//
//import com.gmail.nossr50.commands.skills.AprilCommand;
//import com.gmail.nossr50.config.Config;
//import com.gmail.nossr50.datatypes.interactions.NotificationType;
//import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
//import com.gmail.nossr50.locale.LocaleLoader;
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.util.player.NotificationManager;
//import com.gmail.nossr50.util.player.UserManager;
//import com.gmail.nossr50.util.sounds.SoundManager;
//import com.gmail.nossr50.util.sounds.SoundType;
//import com.google.common.collect.ImmutableList;
//import org.bukkit.ChatColor;
//import org.bukkit.Color;
//import org.bukkit.Statistic;
//import org.bukkit.command.CommandSender;
//import org.bukkit.command.PluginCommand;
//import org.bukkit.entity.Player;
//import org.bukkit.event.player.PlayerStatisticIncrementEvent;
//
//import java.io.*;
//import java.util.*;
//import java.util.regex.Pattern;
//
//public final class HolidayManager {
// private ArrayList<String> hasCelebrated;
// private int currentYear;
// private static final int START_YEAR = 2011;
//
// private static final List<Color> ALL_COLORS;
// private static final List<ChatColor> ALL_CHAT_COLORS;
// private static final List<ChatColor> CHAT_FORMATS;
//
// public enum FakeSkillType {
// MACHO,
// JUMPING,
// THROWING,
// WRECKING,
// CRAFTING,
// WALKING,
// SWIMMING,
// FALLING,
// CLIMBING,
// FLYING,
// DIVING,
// PIGGY,
// UNKNOWN;
//
// public static FakeSkillType getByName(String skillName) {
// for (FakeSkillType type : values()) {
// if (type.name().equalsIgnoreCase(skillName)) {
// return type;
// }
// }
// return null;
// }
//
// public static FakeSkillType getByStatistic(Statistic statistic) {
// switch (statistic) {
// case DAMAGE_TAKEN:
// return FakeSkillType.MACHO;
// case JUMP:
// return FakeSkillType.JUMPING;
// case DROP:
// return FakeSkillType.THROWING;
// case MINE_BLOCK:
// case BREAK_ITEM:
// return FakeSkillType.WRECKING;
// case CRAFT_ITEM:
// return FakeSkillType.CRAFTING;
// case WALK_ONE_CM:
// return FakeSkillType.WALKING;
// case SWIM_ONE_CM:
// return FakeSkillType.SWIMMING;
// case FALL_ONE_CM:
// return FakeSkillType.FALLING;
// case CLIMB_ONE_CM:
// return FakeSkillType.CLIMBING;
// case FLY_ONE_CM:
// return FakeSkillType.FLYING;
// case WALK_UNDER_WATER_ONE_CM:
// return FakeSkillType.DIVING;
// case PIG_ONE_CM:
// return FakeSkillType.PIGGY;
// default:
// return FakeSkillType.UNKNOWN;
// }
// }
// }
//
// public final Set<Statistic> movementStatistics = EnumSet.of(
// Statistic.WALK_ONE_CM, Statistic.SWIM_ONE_CM, Statistic.FALL_ONE_CM,
// Statistic.CLIMB_ONE_CM, Statistic.FLY_ONE_CM, Statistic.WALK_UNDER_WATER_ONE_CM,
// Statistic.PIG_ONE_CM);
//
// static {
// List<Color> colors = new ArrayList<Color>();
// List<ChatColor> chatColors = new ArrayList<ChatColor>();
// List<ChatColor> chatFormats = new ArrayList<ChatColor>();
//
// for (ChatColor color : ChatColor.values()) {
// if (color.isColor()) {
// chatColors.add(color);
// }
// else {
// chatFormats.add(color);
// }
// }
//
//// for (DyeColor color : DyeColor.values()) {
//// colors.add(color.getFireworkColor());
//// }
//
// Collections.shuffle(chatColors, Misc.getRandom());
// Collections.shuffle(colors, Misc.getRandom());
// Collections.shuffle(chatFormats, Misc.getRandom());
//
// ALL_CHAT_COLORS = ImmutableList.copyOf(chatColors);
// ALL_COLORS = ImmutableList.copyOf(colors);
// CHAT_FORMATS = ImmutableList.copyOf(chatFormats);
// }
//
// // This gets called onEnable
// public HolidayManager() {
// currentYear = Calendar.getInstance().get(Calendar.YEAR);
//
// File anniversaryFile = new File(mcMMO.getFlatFileDirectory(), "anniversary." + currentYear + ".yml");
//
// if (!anniversaryFile.exists()) {
// try {
// anniversaryFile.createNewFile();
// }
// catch (IOException ex) {
// mcMMO.p.getLogger().severe(ex.toString());
// }
// }
//
// hasCelebrated = new ArrayList<String>();
//
// try {
// hasCelebrated.clear();
// BufferedReader reader = new BufferedReader(new FileReader(anniversaryFile.getPath()));
// String line = reader.readLine();
//
// while (line != null) {
// hasCelebrated.add(line);
// line = reader.readLine();
// }
//
// reader.close();
// }
// catch (Exception ex) {
// mcMMO.p.getLogger().severe(ex.toString());
// }
//
// cleanupFiles();
// }
//
// private void cleanupFiles() {
// File FlatFileDir = new File(mcMMO.getFlatFileDirectory());
// File legacy = new File(FlatFileDir, "anniversary.yml");
// List<File> toDelete = new ArrayList<File>();
//
// if (legacy.exists()) {
// toDelete.add(legacy);
// }
//
// Pattern pattern = Pattern.compile("anniversary\\.(?:.+)\\.yml");
//
// for (String fileName : FlatFileDir.list()) {
// if (!pattern.matcher(fileName).matches() || fileName.equals("anniversary." + currentYear + ".yml")) {
// continue;
// }
//
// File file = new File(FlatFileDir, fileName);
//
// if (file.isDirectory()) {
// continue;
// }
//
// toDelete.add(file);
// }
//
// for (File file : toDelete) {
// if (file.delete()) {
// mcMMO.p.debug("Deleted: " + file.getName());
// }
// }
// }
//
// // This gets called onDisable
// public void saveAnniversaryFiles() {
// mcMMO.p.debug("Saving anniversary files...");
// String anniversaryFilePath = mcMMO.getFlatFileDirectory() + "anniversary." + currentYear + ".yml";
//
// try {
// BufferedWriter writer = new BufferedWriter(new FileWriter(anniversaryFilePath));
// for (String player : hasCelebrated) {
// writer.write(player);
// writer.newLine();
// }
// writer.close();
// }
// catch (Exception ex) {
// mcMMO.p.getLogger().severe(ex.toString());
// }
// }
//
// // This gets called from /mcmmo command
// public void anniversaryCheck(final CommandSender sender) {
// GregorianCalendar anniversaryStart = new GregorianCalendar(currentYear, Calendar.FEBRUARY, 3);
// GregorianCalendar anniversaryEnd = new GregorianCalendar(currentYear, Calendar.FEBRUARY, 6);
// GregorianCalendar day = new GregorianCalendar();
//
// if (hasCelebrated.contains(sender.getName())) {
// return;
// }
//
// if (!getDateRange(day.getTime(), anniversaryStart.getTime(), anniversaryEnd.getTime())) {
// return;
// }
//
// sender.sendMessage(LocaleLoader.getString("Holiday.Anniversary", (currentYear - START_YEAR)));
// /*if (sender instanceof Player) {
// final int firework_amount = 10;
// for (int i = 0; i < firework_amount; i++) {
// int delay = (int) (Misc.getRandom().nextDouble() * 3 * Misc.TICK_CONVERSION_FACTOR) + 4;
// mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
// @Override
// public void run() {
// spawnFireworks((Player) sender);
// }
// }, delay);
// }
// }*/
//// else {
// /*
// * Credit: http://www.geocities.com/spunk1111/
// * (good luck finding that in 3 years heh)
// * .''. . *''* :_\/_: .
// * :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'.
// * .''.: /\ : /)\ ':'* /\ * : '..'. -=:o:=-
// * :_\/_:'.:::. ' *''* * '.\'/.'_\(/_ '.':'.'
// * : /\ : ::::: *_\/_* -= o =- /)\ '
// * '..' ':::' * /\ * .'/.\'. ' *
// * * *..* : *
// * * * *
// * * * *
// */
//
// /*
// * Color map
// * AAAA D GGGG JJJJJJ K
// * AAAAAA DDDDD EEEGGGGGG JJJJJJ KKKKKKK
// * BBBBAAAAAA DDD EEEGGGGGG I JJJJJ KKKKKKK
// * BBBBBBACCCCC D FFFF G IIIIIIIHHHHH KKKKKKK
// * BBBBBB CCCCC FFFFFF IIIIIII HHH K
// * BBBB CCCCC FFFFFF IIIIIII H k
// * b FFFF I k
// * b i k
// * b i k
// */
// Object[] colorParams = new Object[]{chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose()};
// sender.sendMessage(String.format(" %1$s.''. %4$s. %7$s*''* %10$s:_\\/_: %11$s.", colorParams));
// sender.sendMessage(String.format(" %1$s:_\\/_: %4$s_\\(/_ %5$s.:.%7$s*_\\/_* %10$s: /\\ : %11$s.'.:.'.", colorParams));
// sender.sendMessage(String.format(" %2$s.''.%1$s: /\\ : %4$s/)\\ %5$s':'%7$s* /\\ * %9$s: %10$s'..'. %11$s-=:o:=-", colorParams));
// sender.sendMessage(String.format("%2$s:_\\/_:%1$s'%3$s.:::. %4$s' %6$s*''* %7$s* %9$s'.\\'/.'%8$s_\\(/_ %11$s'.':'.'", colorParams));
// sender.sendMessage(String.format("%2$s: /\\ : %3$s::::: %6$s*_\\/_* %9$s-= o =-%8$s /)\\ %11$s'", colorParams));
// sender.sendMessage(String.format(" %2$s'..' %3$s':::' %6$s* /\\ * %9$s.'/.\\'. %8$s' %11$s*", colorParams));
// sender.sendMessage(String.format(" %2$s* %6$s*..* %9$s: %11$s*", colorParams));
// sender.sendMessage(String.format(" %2$s* %9$s* %11$s*", colorParams));
// sender.sendMessage(String.format(" %2$s* %9$s* %11$s*", colorParams));
//// }
//
// hasCelebrated.add(sender.getName());
// }
//
// public boolean getDateRange(Date date, Date start, Date end) {
// return !(date.before(start) || date.after(end));
// }
//
//// public void spawnFireworks(Player player) {
//// int power = Misc.getRandom().nextInt(3) + 1;
//// Type fireworkType = Type.values()[Misc.getRandom().nextInt(Type.values().length)];
//// double varX = Misc.getRandom().nextGaussian() * 3;
//// double varZ = Misc.getRandom().nextGaussian() * 3;
////
//// Firework fireworks = (Firework) player.getWorld().spawnEntity(player.getLocation().add(varX, 0, varZ), EntityType.FIREWORK);
//// FireworkMeta fireworkmeta = fireworks.getFireworkMeta();
//// FireworkEffect effect = FireworkEffect.builder().flicker(Misc.getRandom().nextBoolean()).withColor(colorChoose()).withFade(colorChoose()).with(fireworkType).trail(Misc.getRandom().nextBoolean()).build();
//// fireworkmeta.addEffect(effect);
//// fireworkmeta.setPower(power);
//// fireworks.setFireworkMeta(fireworkmeta);
//// }
//
// private static List<Color> colorChoose() {
// return ALL_COLORS.subList(0, Math.max(Misc.getRandom().nextInt(ALL_COLORS.size() + 1), 1));
// }
//
// private static String chatColorChoose() {
// StringBuilder ret = new StringBuilder(ALL_CHAT_COLORS.get(Misc.getRandom().nextInt(ALL_CHAT_COLORS.size())).toString());
//
// for (ChatColor chatFormat : CHAT_FORMATS) {
// if (Misc.getRandom().nextInt(CHAT_FORMATS.size()) == 0) {
// ret.append(chatFormat);
// }
// }
//
// return ret.toString();
// }
//
// public boolean isAprilFirst() {
// if(!Config.getInstance().isAprilFoolsAllowed())
// return false;
//
// GregorianCalendar aprilFirst = new GregorianCalendar(currentYear, Calendar.APRIL, 1);
// GregorianCalendar aprilSecond = new GregorianCalendar(currentYear, Calendar.APRIL, 2);
// GregorianCalendar day = new GregorianCalendar();
// return getDateRange(day.getTime(), aprilFirst.getTime(), aprilSecond.getTime());
// }
//
// public boolean nearingAprilFirst() {
// if(!Config.getInstance().isAprilFoolsAllowed())
// return false;
//
// GregorianCalendar start = new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), Calendar.MARCH, 28);
// GregorianCalendar end = new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), Calendar.APRIL, 2);
// GregorianCalendar day = new GregorianCalendar();
//
// return mcMMO.getHolidayManager().getDateRange(day.getTime(), start.getTime(), end.getTime());
// }
//
// public void handleStatisticEvent(PlayerStatisticIncrementEvent event) {
// Player player = event.getPlayer();
// Statistic statistic = event.getStatistic();
// int newValue = event.getNewValue();
//
// int modifier;
// switch (statistic) {
// case DAMAGE_TAKEN:
// modifier = 500;
// break;
// case JUMP:
// modifier = 500;
// break;
// case DROP:
// modifier = 200;
// break;
// case MINE_BLOCK:
// case BREAK_ITEM:
// modifier = 500;
// break;
// case CRAFT_ITEM:
// modifier = 100;
// break;
// default:
// return;
// }
//
// if (newValue % modifier == 0) {
// mcMMO.getHolidayManager().levelUpApril(player, FakeSkillType.getByStatistic(statistic));
// }
// }
//
// public void levelUpApril(Player player, FakeSkillType fakeSkillType) {
// if(!Config.getInstance().isAprilFoolsAllowed())
// return;
//
// int levelTotal = Misc.getRandom().nextInt(1 + UserManager.getPlayer(player).getSkillLevel(PrimarySkillType.MINING)) + 1;
// SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP);
// NotificationManager.sendPlayerInformation(player, NotificationType.HOLIDAY, "Holiday.AprilFools.Levelup", StringUtils.getCapitalized(fakeSkillType.toString()), String.valueOf(levelTotal));
//// ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size())));
// }
//
// public void registerAprilCommand() {
// if(!Config.getInstance().isAprilFoolsAllowed())
// return;
//
// PluginCommand command = mcMMO.p.getCommand("mcfools");
// command.setExecutor(new AprilCommand());
// }
//}

View File

@ -0,0 +1,282 @@
//package com.gmail.nossr50.util;
//
//import com.gmail.nossr50.config.MainConfig;
//import com.gmail.nossr50.config.mods.CustomArmorConfig;
//import com.gmail.nossr50.config.mods.CustomBlockConfig;
//import com.gmail.nossr50.config.mods.CustomEntityConfig;
//import com.gmail.nossr50.config.mods.CustomToolConfig;
//import com.gmail.nossr50.datatypes.mods.CustomBlock;
//import com.gmail.nossr50.datatypes.mods.CustomEntity;
//import com.gmail.nossr50.datatypes.mods.CustomTool;
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.skills.repair.repairables.Repairable;
//import org.bukkit.Material;
//import org.bukkit.block.BlockState;
//import org.bukkit.configuration.file.YamlConfiguration;
//import org.bukkit.entity.Entity;
//import org.bukkit.inventory.ItemStack;
//
//import java.io.File;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//
//public class ModManager {
// /*private List<Repairable> repairables = new ArrayList<Repairable>();
//
// // Armor Mods
// private List<Material> customBoots = new ArrayList<Material>();
// private List<Material> customChestplates = new ArrayList<Material>();
// private List<Material> customHelmets = new ArrayList<Material>();
// private List<Material> customLeggings = new ArrayList<Material>();
//
// // Block Mods
// private List<Material> customExcavationBlocks = new ArrayList<Material>();
// private List<Material> customHerbalismBlocks = new ArrayList<Material>();
// private List<Material> customMiningBlocks = new ArrayList<Material>();
// private List<Material> customOres = new ArrayList<Material>();
// private List<Material> customLogs = new ArrayList<Material>();
// private List<Material> customLeaves = new ArrayList<Material>();
// private List<Material> customAbilityBlocks = new ArrayList<Material>();
// private HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
//
// // Entity Mods
// private HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
// private HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
//
// // Tool Mods
// private List<Material> customAxes = new ArrayList<Material>();
// private List<Material> customBows = new ArrayList<Material>();
// private List<Material> customHoes = new ArrayList<Material>();
// private List<Material> customPickaxes = new ArrayList<Material>();
// private List<Material> customShovels = new ArrayList<Material>();
// private List<Material> customSwords = new ArrayList<Material>();
// private HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
//
// public void registerCustomArmor(CustomArmorConfig config) {
// customBoots.addAll(config.customBoots);
// customChestplates.addAll(config.customChestplates);
// customHelmets.addAll(config.customHelmets);
// customLeggings.addAll(config.customLeggings);
// repairables.addAll(config.repairables);
// }
//
// public void registerCustomBlocks(CustomBlockConfig config) {
// customExcavationBlocks.addAll(config.customExcavationBlocks);
// customHerbalismBlocks.addAll(config.customHerbalismBlocks);
// customMiningBlocks.addAll(config.customMiningBlocks);
// customOres.addAll(config.customOres);
// customLogs.addAll(config.customLogs);
// customLeaves.addAll(config.customLeaves);
// customAbilityBlocks.addAll(config.customAbilityBlocks);
// customBlockMap.putAll(config.customBlockMap);
// }
//
// public void registerCustomEntities(CustomEntityConfig config) {
// customEntityClassMap.putAll(config.customEntityClassMap);
// customEntityTypeMap.putAll(config.customEntityTypeMap);
// }
//
// public void registerCustomTools(CustomToolConfig config) {
// customAxes.addAll(config.customAxes);
// customBows.addAll(config.customBows);
// customHoes.addAll(config.customHoes);
// customPickaxes.addAll(config.customPickaxes);
// customShovels.addAll(config.customShovels);
// customSwords.addAll(config.customSwords);
// customToolMap.putAll(config.customToolMap);
// repairables.addAll(config.repairables);
// }
//
// public boolean isCustomBoots(Material material) {
// return MainConfig.getInstance().getArmorModsEnabled() && customBoots.contains(material);
// }
//
// public boolean isCustomChestplate(Material material) {
// return MainConfig.getInstance().getArmorModsEnabled() && customChestplates.contains(material);
// }
//
// public boolean isCustomHelmet(Material material) {
// return MainConfig.getInstance().getArmorModsEnabled() && customHelmets.contains(material);
// }
//
// public boolean isCustomLeggings(Material material) {
// return MainConfig.getInstance().getArmorModsEnabled() && customLeggings.contains(material);
// }
//
// public boolean isCustomAxe(Material material) {
// return MainConfig.getInstance().getToolModsEnabled() && customAxes.contains(material);
// }
//
// public boolean isCustomBow(Material material) {
// return MainConfig.getInstance().getToolModsEnabled() && customBows.contains(material);
// }
//
// public boolean isCustomHoe(Material material) {
// return MainConfig.getInstance().getToolModsEnabled() && customHoes.contains(material);
// }
//
// public boolean isCustomPickaxe(Material material) {
// return MainConfig.getInstance().getToolModsEnabled() && customPickaxes.contains(material);
// }
//
// public boolean isCustomShovel(Material material) {
// return MainConfig.getInstance().getToolModsEnabled() && customShovels.contains(material);
// }
//
// public boolean isCustomSword(Material material) {
// return MainConfig.getInstance().getToolModsEnabled() && customSwords.contains(material);
// }
//
// public boolean isCustomOre(Material data) {
// return MainConfig.getInstance().getBlockModsEnabled() && customOres.contains(data);
// }
//
// public boolean isCustomLog(BlockState state) {
// return MainConfig.getInstance().getBlockModsEnabled() && customLogs.contains(state.getType());
// }
//
// public boolean isCustomLeaf(BlockState state) {
// return MainConfig.getInstance().getBlockModsEnabled() && customLeaves.contains(state.getType());
// }
//
// public boolean isCustomAbilityBlock(BlockState state) {
// return MainConfig.getInstance().getBlockModsEnabled() && customAbilityBlocks.contains(state.getType());
// }
//
// public boolean isCustomExcavationBlock(BlockState state) {
// return MainConfig.getInstance().getBlockModsEnabled() && customExcavationBlocks.contains(state.getType());
// }
//
// public boolean isCustomHerbalismBlock(BlockState state) {
// return MainConfig.getInstance().getBlockModsEnabled() && customHerbalismBlocks.contains(state.getType());
// }
//
// public boolean isCustomMiningBlock(BlockState state) {
// return MainConfig.getInstance().getBlockModsEnabled() && customMiningBlocks.contains(state.getType());
// }
//
// public CustomBlock getBlock(BlockState state) {
// return customBlockMap.get(state.getType());
// }
//
// public CustomBlock getBlock(Material data) {
// return customBlockMap.get(data);
// }
//
// *//**
// * Checks to see if an item is a custom tool.
// *
// * @param item Item to check
// * @return true if the item is a custom tool, false otherwise
// *//*
// public boolean isCustomTool(ItemStack item) {
// return MainConfig.getInstance().getToolModsEnabled() && item != null && customToolMap.containsKey(item.getType());
// }
//
// *//**
// * Get the custom tool associated with an item.
// *
// * @param item The item to check
// * @return the tool if it exists, null otherwise
// *//*
// public CustomTool getTool(ItemStack item) {
// return item == null ? null : customToolMap.get(item.getType());
// }
//
// public List<Repairable> getLoadedRepairables() {
// return repairables;
// }
//
// public boolean isCustomEntity(Entity entity) {
// if (!MainConfig.getInstance().getEntityModsEnabled()) {
// return false;
// }
//
// if (customEntityTypeMap.containsKey(entity.getType().toString())) {
// return true;
// }
//
// try {
// return customEntityClassMap.containsKey(((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName());
// }
// catch (Exception e) {
// if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
// return customEntityClassMap.containsKey(entity.getClass().getName());
// }
//
// e.printStackTrace();
// return false;
// }
// }
//
// public CustomEntity getEntity(Entity entity) {
// CustomEntity customEntity = customEntityTypeMap.get(entity.getType().toString());
//
// if (customEntity == null) {
// try {
// customEntity = customEntityClassMap.get(((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName());
// }
// catch (Exception e) {
// if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
// customEntity = customEntityClassMap.get(entity.getClass().getName());
// }
// else {
// e.printStackTrace();
// }
// }
// }
//
// return customEntity;
// }
//
// public void addCustomEntity(Entity entity) {
// if (!MainConfig.getInstance().getEntityModsEnabled()) {
// return;
// }
//
// File entityFile = new File(mcMMO.p.getDataFolder(), "mods" + File.separator + "entities.default.yml");
// YamlConfiguration entitiesFile = YamlConfiguration.loadConfiguration(entityFile);
//
// String entityName = entity.getType().toString();
// String sanitizedEntityName = entityName.replace(".", "_");
//
// if (entitiesFile.getKeys(false).contains(sanitizedEntityName)) {
// return;
// }
//
// entitiesFile.set(sanitizedEntityName + ".XP_Multiplier", 1.0D);
// entitiesFile.set(sanitizedEntityName + ".Tameable", false);
// entitiesFile.set(sanitizedEntityName + ".Taming_XP", 0);
// entitiesFile.set(sanitizedEntityName + ".CanBeSummoned", false);
// entitiesFile.set(sanitizedEntityName + ".COTW_Material", "");
// entitiesFile.set(sanitizedEntityName + ".COTW_Material_Data", 0);
// entitiesFile.set(sanitizedEntityName + ".COTW_Material_Amount", 0);
//
// String className = "";
//
// try {
// className = ((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName();
// }
// catch (Exception e) {
// if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
// className = entity.getClass().getName();
// }
// else {
// e.printStackTrace();
// }
// }
//
// CustomEntity customEntity = new CustomEntity(1.0D, false, 0, false, null, 0);
// customEntityTypeMap.put(entityName, customEntity);
// customEntityClassMap.put(className, customEntity);
//
// try {
// entitiesFile.save(entityFile);
// mcMMO.p.debug(entity.getType().toString() + " was added to the custom entities file!");
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }*/
//}

View File

@ -0,0 +1,740 @@
//package com.gmail.nossr50.skills.alchemy;
//
//import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
//import com.gmail.nossr50.mcMMO;
//import org.bukkit.ChatColor;
//import org.bukkit.Color;
//import org.bukkit.Material;
//import org.bukkit.potion.PotionData;
//import org.bukkit.potion.PotionEffect;
//import org.bukkit.potion.PotionEffectType;
//import org.bukkit.potion.PotionType;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.Map.Entry;
//
///**
// * This class is an abomination
// * Alchemy will be rewritten, unfortunately during 2.2 (the config rewrite) I stumbled upon this class
// * This class is far from proper, however due to the nature of how the current implementation of Alchemy works, it'd be a royal pain to rewrite this class to "fix" it
// * Especially considering I plan to rewrite Alchemy, it does not seem worth the time involved to fix this monster
// *
// * Shield your eyes
// * It was worse before I cleaned it up
// */
//public class PotionGenerator {
// private HashMap<String, AlchemyPotion> potionHashMap;
//// private HashMap<ProtoPotion, HashMap<Ingredient, ProtoPotion>> childPotionMap; //Yuck
//
// public PotionGenerator() {
// potionHashMap = new HashMap<>();
//// childPotionMap = new HashMap<>();
// init();
// }
//
// private void init() {
// Map<ProtoPotion, Map<Ingredient, ProtoPotion>> vanillaPotions = new HashMap<>();
// Map<ProtoPotion, Map<Ingredient, ProtoPotion>> mcMMOPotions = new HashMap<>();
//
// populateVanillaPotions(vanillaPotions);
// populateCustomPotions(mcMMOPotions);
//
// List<ProtoPotion> sorted = new ArrayList<>();
//
// sorted.addAll(vanillaPotions.keySet());
// sorted.addAll(mcMMOPotions.keySet());
//
// sorted.sort((a, b) -> {
// // All normal potions first
// if (a.mat == Material.POTION && b.mat != Material.POTION) {
// return -1;
// }
// if (b.mat == Material.POTION && a.mat != Material.POTION) {
// return 1;
// }
// // All splash potions second
// if (a.mat == Material.SPLASH_POTION && b.mat != Material.SPLASH_POTION) {
// return -1;
// }
// if (b.mat == Material.SPLASH_POTION && a.mat != Material.SPLASH_POTION) {
// return 1;
// }
// // Vanilla Potions first
// if (a.effect == null && b.effect != null) {
// return -1;
// }
// if (b.effect == null && a.effect != null) {
// return 1;
// }
// // Vanilla potions
// if (a.effect == null && b.effect == null) {
// // Order by PotionType
// if (a.data.getType() != b.data.getType()) {
// return Integer.compare(a.data.getType().ordinal(), b.data.getType().ordinal());
// }
// // Plain before extended or upgraded
// if (!a.data.isExtended() && !a.data.isUpgraded() && (b.data.isExtended() || b.data.isUpgraded())) {
// return -1;
// }
// if (!b.data.isExtended() && !b.data.isUpgraded() && (a.data.isExtended() || a.data.isUpgraded())) {
// return 1;
// }
// // Extended before Upgraded
// if (a.data.isExtended() && b.data.isUpgraded()) {
// return -1;
// }
// if (b.data.isExtended() && a.data.isUpgraded()) {
// return -1;
// }
// // Same potion somehow?
// return 0;
// }
// // mcMMO Potions
// else {
// if ((a.baseName.contains("II") || a.baseName.contains("EXTENDED")) && !(b.baseName.contains("II") || b.baseName.contains("EXTENDED"))) {
// return 1;
// }
// if ((b.baseName.contains("II") || b.baseName.contains("EXTENDED")) && !(a.baseName.contains("II") || a.baseName.contains("EXTENDED"))) {
// return -1;
// }
// if (!a.baseName.contains("II") && b.baseName.contains("II")) {
// return -1;
// }
// if (!b.baseName.contains("II") && a.baseName.contains("II")) {
// return 1;
// }
// return a.baseName.split("_")[0].compareTo(b.baseName.split("_")[0]);
// }
// });
//
// /* Hacky solution, this entire class disgusts me */
// HashMap<String, AlchemyPotion> potionHashMap = new HashMap<>();
//
// for(ProtoPotion potion : sorted)
// {
// AlchemyPotion alchemyPotion;
//
// if(vanillaPotions.containsKey(potion)) {
// potion getChildren(potion);
//
// } else {
// getChildren(potion);
// }
// potionHashMap.put(alchemyPotion.getName(), alchemyPotion);
// }
//
//// for (ProtoPotion potion : sorted) {
//// System.out.println(" " + potion.name + ":");
//// Map<Ingredient, ProtoPotion> children;
//// if (vanillaPotions.containsKey(potion)) {
//// children = vanillaPotions.get(potion);
//// } else {
//// System.out.println(" Name: " + prettify(potion.name));
//// children = mcMMOPotions.get(potion);
//// }
//// System.out.println(" Material: " + potion.mat.name());
//// System.out.println(" PotionData:");
//// System.out.println(" PotionType: " + potion.data.getType().name());
//// if (potion.data.isExtended()) {
//// System.out.println(" Extended: true");
//// }
//// if (potion.data.isUpgraded()) {
//// System.out.println(" Upgraded: true");
//// }
//// if (potion.effect != null) {
//// System.out.println(" Effects: [\"" + getName(potion.effect.getType()) + " " + potion.effect.getAmplifier() + " " + potion.effect.getDuration() + "\"]");
//// }
//// if (children == null || children.isEmpty()) {
//// continue;
//// }
//// System.out.println(" Children:");
//// for (Entry<Ingredient, ProtoPotion> child : children.entrySet()) {
//// System.out.println(" " + child.getKey().name + ": " + child.getValue().name);
//// }
//// }
// }
//
// public HashMap<String, AlchemyPotion> getPotionHashMap() {
// return potionHashMap;
// }
//
// /**
// * I just want anyone who reads this to know
// * This entire class is an abomination
// * What you see below is a hacky solution to keep Alchemy functioning with the new config system
// * Alchemy will be rewritten, until then, this disgusting class exists.
// * @param protoPotion target ProtoPotion
// * @return converted ProtoPotion
// */
// private AlchemyPotion convertWriteableToAlchemyPotion(ProtoPotion protoPotion, ) {
// try {
//
// String name = protoPotion.name;
//
// if (name != null) {
// name = prettify(ChatColor.translateAlternateColorCodes('&', name));
// }
//
// PotionData data = protoPotion.data;
// Material material = Material.POTION;
//
// if(protoPotion.mat != null)
// material = protoPotion.mat;
//
// //Lore is unused as far as I can tell
// List<String> lore = new ArrayList<>();
//
// List<PotionEffect> effects = new ArrayList<>();
// effects.add(protoPotion.effect);
//
// Color color = this.generateColor(effects);
//
//
// return new AlchemyPotion(material, data, name, lore, effects, color, getChildren(protoPotion));
// } catch (Exception e) {
// mcMMO.p.getLogger().warning("Failed to load Alchemy potion: " + potion_section.getString());
// return null;
// }
// }
//
// public Color generateColor(List<PotionEffect> effects) {
// if (effects != null && !effects.isEmpty()) {
// List<Color> colors = new ArrayList<>();
// for (PotionEffect effect : effects) {
// if (effect.getType().getColor() != null) {
// colors.add(effect.getType().getColor());
// }
// }
// if (!colors.isEmpty()) {
// if (colors.size() > 1) {
// return calculateAverageColor(colors);
// }
// return colors.get(0);
// }
// }
// return null;
// }
//
// public Color calculateAverageColor(List<Color> colors) {
// int red = 0;
// int green = 0;
// int blue = 0;
// for (Color color : colors) {
// red += color.getRed();
// green += color.getGreen();
// blue += color.getBlue();
// }
// Color color = Color.fromRGB(red / colors.size(), green / colors.size(), blue / colors.size());
// return color;
// }
//
// private static String prettify(String name) {
// String[] substrings = name.split("_");
// String prettyString = "";
// int size = 1;
//
// for (String string : substrings) {
// prettyString = prettyString.concat(getCapitalized(string));
//
// if (size < substrings.length) {
// prettyString = prettyString.concat(" ");
// }
//
// size++;
// }
//
// return prettyString;
// }
//
// public static String getCapitalized(String target) {
// if (target.equals("II")) { // hacks
// return target;
// }
// return target.substring(0, 1).toUpperCase() + target.substring(1).toLowerCase();
// }
//
// private static String getName(PotionEffectType type) {
// switch (type.getId()) {
// case 1:
// return "SPEED";
// case 2:
// return "SLOW";
// case 3:
// return "FAST_DIGGING";
// case 4:
// return "SLOW_DIGGING";
// case 5:
// return "INCREASE_DAMAGE";
// case 6:
// return "HEAL";
// case 7:
// return "HARM";
// case 8:
// return "JUMP";
// case 9:
// return "CONFUSION";
// case 10:
// return "REGENERATION";
// case 11:
// return "DAMAGE_RESISTANCE";
// case 12:
// return "FIRE_RESISTANCE";
// case 13:
// return "WATER_BREATHING";
// case 14:
// return "INVISIBILITY";
// case 15:
// return "BLINDNESS";
// case 16:
// return "NIGHT_VISION";
// case 17:
// return "HUNGER";
// case 18:
// return "WEAKNESS";
// case 19:
// return "POISON";
// case 20:
// return "WITHER";
// case 21:
// return "HEALTH_BOOST";
// case 22:
// return "ABSORPTION";
// case 23:
// return "SATURATION";
// case 24:
// return "GLOWING";
// case 25:
// return "LEVITATION";
// case 26:
// return "LUCK";
// case 27:
// return "UNLUCK";
// case 28:
// return "SLOW_FALLING";
// case 29:
// return "CONDUIT_POWER";
// case 30:
// return "DOLPHINS_GRACE";
// default:
// return "UNKNOWN_EFFECT_TYPE_" + type.getId();
// }
// }
//
// private void populateVanillaPotions(Map<ProtoPotion, Map<Ingredient, ProtoPotion>> vanillaPotions) {
// for (PotionType type : PotionType.values()) {
// for (Material material : new Material[]{Material.POTION, Material.SPLASH_POTION, Material.LINGERING_POTION}) {
// ProtoPotion protoPotion = new ProtoPotion(material, type);
// getChildren(protoPotion);
// vanillaPotions.put(protoPotion, getChildren(protoPotion));
// if (type.isExtendable()) {
// protoPotion = new ProtoPotion(material, new PotionData(type, true, false));
// vanillaPotions.put(protoPotion, getChildren(protoPotion));
// }
// if (type.isUpgradeable()) {
// protoPotion = new ProtoPotion(material, new PotionData(type, false, true));
// vanillaPotions.put(protoPotion, getChildren(protoPotion));
// }
// }
// }
// for (Entry<ProtoPotion, Map<Ingredient, ProtoPotion>> entry : vanillaPotions.entrySet()) {
// if (entry.getKey().mat == Material.POTION) {
// entry.getValue().put(new Ingredient(Material.GUNPOWDER), new ProtoPotion(Material.SPLASH_POTION, entry.getKey().data));
// }
// if (entry.getKey().mat == Material.SPLASH_POTION) {
// entry.getValue().put(new Ingredient(Material.DRAGON_BREATH), new ProtoPotion(Material.LINGERING_POTION, entry.getKey().data));
// }
// }
//
// //Store children
// }
//
// private HashMap<Ingredient, ProtoPotion> getChildren(ProtoPotion protoPotion) {
// HashMap<Ingredient, ProtoPotion> children = new HashMap<>();
//
// switch (protoPotion.data.getType()) {
// case WATER:
// assert (!protoPotion.data.isExtended());
// assert (!protoPotion.data.isUpgraded());
// children.put(new Ingredient(Material.NETHER_WART), new ProtoPotion(protoPotion.mat, PotionType.AWKWARD));
// children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new ProtoPotion(protoPotion.mat, PotionType.WEAKNESS));
// children.put(new Ingredient(Material.REDSTONE), new ProtoPotion(protoPotion.mat, PotionType.MUNDANE));
// children.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(protoPotion.mat, PotionType.THICK));
// children.put(new Ingredient(Material.BLAZE_POWDER), new ProtoPotion(protoPotion.mat, PotionType.MUNDANE));
// children.put(new Ingredient(Material.SUGAR), new ProtoPotion(protoPotion.mat, PotionType.MUNDANE));
// children.put(new Ingredient(Material.RABBIT_FOOT), new ProtoPotion(protoPotion.mat, PotionType.MUNDANE));
// children.put(new Ingredient(Material.SPIDER_EYE), new ProtoPotion(protoPotion.mat, PotionType.MUNDANE));
// children.put(new Ingredient(Material.MAGMA_CREAM), new ProtoPotion(protoPotion.mat, PotionType.MUNDANE));
// children.put(new Ingredient(Material.GLISTERING_MELON_SLICE), new ProtoPotion(protoPotion.mat, PotionType.MUNDANE));
// children.put(new Ingredient(Material.GHAST_TEAR), new ProtoPotion(protoPotion.mat, PotionType.MUNDANE));
// return children;
// case AWKWARD:
// assert (!protoPotion.data.isExtended());
// assert (!protoPotion.data.isUpgraded());
// children.put(new Ingredient(Material.GOLDEN_CARROT), new ProtoPotion(protoPotion.mat, PotionType.NIGHT_VISION));
// children.put(new Ingredient(Material.RABBIT_FOOT), new ProtoPotion(protoPotion.mat, PotionType.JUMP));
// children.put(new Ingredient(Material.MAGMA_CREAM), new ProtoPotion(protoPotion.mat, PotionType.FIRE_RESISTANCE));
// children.put(new Ingredient(Material.SUGAR), new ProtoPotion(protoPotion.mat, PotionType.SPEED));
// children.put(new Ingredient(Material.PUFFERFISH), new ProtoPotion(protoPotion.mat, PotionType.WATER_BREATHING));
// children.put(new Ingredient(Material.GLISTERING_MELON_SLICE), new ProtoPotion(protoPotion.mat, PotionType.INSTANT_HEAL));
// children.put(new Ingredient(Material.SPIDER_EYE), new ProtoPotion(protoPotion.mat, PotionType.POISON));
// children.put(new Ingredient(Material.GHAST_TEAR), new ProtoPotion(protoPotion.mat, PotionType.REGEN));
// children.put(new Ingredient(Material.BLAZE_POWDER), new ProtoPotion(protoPotion.mat, PotionType.STRENGTH));
// children.put(new Ingredient(Material.TURTLE_HELMET), new ProtoPotion(protoPotion.mat, PotionType.TURTLE_MASTER));
// children.put(new Ingredient(Material.PHANTOM_MEMBRANE), new ProtoPotion(protoPotion.mat, PotionType.SLOW_FALLING));
// // mcMMO custom potions
// double mod = 1;
// if (protoPotion.mat == Material.SPLASH_POTION) {
// mod = 0.75;
// }
// if (protoPotion.mat == Material.LINGERING_POTION) {
// mod = 0.25;
// }
// children.put(new Ingredient(Material.BROWN_MUSHROOM), new ProtoPotion(protoPotion.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.CONFUSION, (int) (450 * mod), 0), "NAUSEA"));
// children.put(new Ingredient(Material.CARROT), new ProtoPotion(protoPotion.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.FAST_DIGGING, (int) (3600 * mod), 0), "HASTE"));
// children.put(new Ingredient(Material.SLIME_BALL), new ProtoPotion(protoPotion.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.SLOW_DIGGING, (int) (3600 * mod), 0), "DULLNESS"));
// children.put(new Ingredient(Material.GOLDEN_APPLE), new ProtoPotion(protoPotion.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, (int) (450 * mod), 0), "RESISTANCE"));
// children.put(new Ingredient(Material.INK_SAC), new ProtoPotion(protoPotion.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.BLINDNESS, (int) (225 * mod), 0), "BLINDNESS"));
// children.put(new Ingredient(Material.ROTTEN_FLESH), new ProtoPotion(protoPotion.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.HUNGER, (int) (900 * mod), 0), "HUNGER"));
// children.put(new Ingredient(Material.POISONOUS_POTATO), new ProtoPotion(protoPotion.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.WITHER, (int) (450 * mod), 0), "DECAY"));
// children.put(new Ingredient(Material.QUARTZ), new ProtoPotion(protoPotion.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.ABSORPTION, (int) (1800 * mod), 0), "ABSORPTION"));
// children.put(new Ingredient(Material.FERN), new ProtoPotion(protoPotion.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.SATURATION, (int) (8 * mod), 0), "SATURATION"));
// children.put(new Ingredient(Material.APPLE), new ProtoPotion(protoPotion.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.HEALTH_BOOST, (int) (1800 * mod), 0), "HEALTH_BOOST"));
// return children;
// case FIRE_RESISTANCE:
// assert (!protoPotion.data.isUpgraded());
// if (protoPotion.data.isExtended()) {
// children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new ProtoPotion(protoPotion.mat, new PotionData(PotionType.SLOWNESS, true, false)));
// } else {
// children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new ProtoPotion(protoPotion.mat, PotionType.SLOWNESS));
// children.put(new Ingredient(Material.REDSTONE), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), true, false)));
// }
// return children;
// case INSTANT_DAMAGE:
// assert (!protoPotion.data.isExtended());
// if (!protoPotion.data.isUpgraded()) {
// children.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), false, true)));
// }
// return children;
// case INSTANT_HEAL:
// assert (!protoPotion.data.isExtended());
// if (!protoPotion.data.isUpgraded()) {
// children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new ProtoPotion(protoPotion.mat, PotionType.INSTANT_DAMAGE));
// children.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), false, true)));
// } else {
// children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new ProtoPotion(protoPotion.mat, new PotionData(PotionType.INSTANT_DAMAGE, false, true)));
// }
// return children;
// case INVISIBILITY:
// assert (!protoPotion.data.isUpgraded());
// if (!protoPotion.data.isExtended()) {
// children.put(new Ingredient(Material.REDSTONE), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), true, false)));
// }
// return children;
// case JUMP:
// if (!protoPotion.data.isUpgraded() && !protoPotion.data.isExtended()) {
// children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new ProtoPotion(protoPotion.mat, PotionType.SLOWNESS));
// children.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), false, true)));
// children.put(new Ingredient(Material.REDSTONE), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), true, false)));
// }
// return children;
// case NIGHT_VISION:
// assert (!protoPotion.data.isUpgraded());
// if (!protoPotion.data.isExtended()) {
// children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new ProtoPotion(protoPotion.mat, PotionType.INVISIBILITY));
// children.put(new Ingredient(Material.REDSTONE), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), true, false)));
// } else {
// children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new ProtoPotion(protoPotion.mat, new PotionData(PotionType.INVISIBILITY, true, false)));
// }
// return children;
// case POISON:
// if (!protoPotion.data.isUpgraded() && !protoPotion.data.isExtended()) {
// children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new ProtoPotion(protoPotion.mat, PotionType.INSTANT_DAMAGE));
// children.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), false, true)));
// children.put(new Ingredient(Material.REDSTONE), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), true, false)));
// } else {
// children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new ProtoPotion(protoPotion.mat, new PotionData(PotionType.INSTANT_DAMAGE, false, true)));
// }
// return children;
// case REGEN:
// if (!protoPotion.data.isUpgraded() && !protoPotion.data.isExtended()) {
// children.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), false, true)));
// children.put(new Ingredient(Material.REDSTONE), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), true, false)));
// }
// return children;
// case SLOWNESS:
// assert (!protoPotion.data.isUpgraded());
// if (!protoPotion.data.isExtended()) {
// children.put(new Ingredient(Material.REDSTONE), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), true, false)));
// }
// return children;
// case SLOW_FALLING:
// assert (!protoPotion.data.isUpgraded());
// if (!protoPotion.data.isExtended()) {
// children.put(new Ingredient(Material.REDSTONE), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), true, false)));
// }
// return children;
// case SPEED:
// if (!protoPotion.data.isUpgraded() && !protoPotion.data.isExtended()) {
// children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new ProtoPotion(protoPotion.mat, PotionType.SLOWNESS));
// children.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), false, true)));
// children.put(new Ingredient(Material.REDSTONE), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), true, false)));
// } else {
// children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new ProtoPotion(protoPotion.mat, new PotionData(PotionType.SLOWNESS, true, false)));
// }
// return children;
// case STRENGTH:
// if (!protoPotion.data.isUpgraded() && !protoPotion.data.isExtended()) {
// children.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), false, true)));
// children.put(new Ingredient(Material.REDSTONE), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), true, false)));
// }
// return children;
// case TURTLE_MASTER:
// if (!protoPotion.data.isUpgraded() && !protoPotion.data.isExtended()) {
// children.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), false, true)));
// children.put(new Ingredient(Material.REDSTONE), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), true, false)));
// }
// return children;
// case WATER_BREATHING:
// assert (!protoPotion.data.isUpgraded());
// if (!protoPotion.data.isExtended()) {
// children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new ProtoPotion(protoPotion.mat, PotionType.INSTANT_DAMAGE));
// children.put(new Ingredient(Material.REDSTONE), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), true, false)));
// }
// return children;
// case WEAKNESS:
// assert (!protoPotion.data.isUpgraded());
// if (!protoPotion.data.isExtended()) {
// children.put(new Ingredient(Material.REDSTONE), new ProtoPotion(protoPotion.mat, new PotionData(protoPotion.data.getType(), true, false)));
// }
// return children;
// case LUCK:
// case MUNDANE:
// case THICK:
// case UNCRAFTABLE:
// assert (!protoPotion.data.isExtended());
// assert (!protoPotion.data.isUpgraded());
// return children;
// default:
// return children;
// }
// }
//
// private static void populateCustomPotions(Map<ProtoPotion, Map<Ingredient, ProtoPotion>> customPotions) {
// for (Material material : new Material[]{Material.POTION, Material.SPLASH_POTION, Material.LINGERING_POTION}) {
// ProtoPotion newPotion;
// double mod = 1;
// if (material == Material.SPLASH_POTION) {
// mod = 0.75;
// }
// if (material == Material.LINGERING_POTION) {
// mod = 0.25;
// }
// HashMap<Ingredient, ProtoPotion> newPotionChildren;
// newPotion = new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.CONFUSION, (int) (450 * mod), 0), "NAUSEA");
// newPotionChildren = new HashMap<>();
// newPotionChildren.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() / 2, 1), newPotion.baseName + "_II"));
// newPotionChildren.put(new Ingredient(Material.REDSTONE), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() * 2, 0), newPotion.baseName + "_EXTENDED"));
// for (ProtoPotion child : newPotionChildren.values()) {
// customPotions.put(child, new HashMap<>());
// }
// customPotions.put(newPotion, newPotionChildren);
// newPotion = new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.FAST_DIGGING, (int) (3600 * mod), 0), "HASTE");
// newPotionChildren = new HashMap<>();
// newPotionChildren.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() / 2, 1), newPotion.baseName + "_II"));
// newPotionChildren.put(new Ingredient(Material.REDSTONE), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() * 2, 0), newPotion.baseName + "_EXTENDED"));
// for (ProtoPotion child : newPotionChildren.values()) {
// customPotions.put(child, new HashMap<>());
// }
// customPotions.put(newPotion, newPotionChildren);
// newPotion = new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.SLOW_DIGGING, (int) (3600 * mod), 0), "DULLNESS");
// newPotionChildren = new HashMap<>();
// newPotionChildren.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() / 2, 1), newPotion.baseName + "_II"));
// newPotionChildren.put(new Ingredient(Material.REDSTONE), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() * 2, 0), newPotion.baseName + "_EXTENDED"));
// for (ProtoPotion child : newPotionChildren.values()) {
// customPotions.put(child, new HashMap<>());
// }
// customPotions.put(newPotion, newPotionChildren);
// newPotion = new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, (int) (450 * mod), 0), "RESISTANCE");
// newPotionChildren = new HashMap<>();
// newPotionChildren.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() / 2, 1), newPotion.baseName + "_II"));
// newPotionChildren.put(new Ingredient(Material.REDSTONE), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() * 2, 0), newPotion.baseName + "_EXTENDED"));
// for (ProtoPotion child : newPotionChildren.values()) {
// customPotions.put(child, new HashMap<>());
// }
// customPotions.put(newPotion, newPotionChildren);
// newPotion = new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.BLINDNESS, (int) (225 * mod), 0), "BLINDNESS");
// newPotionChildren = new HashMap<>();
// newPotionChildren.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() / 2, 1), newPotion.baseName + "_II"));
// newPotionChildren.put(new Ingredient(Material.REDSTONE), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() * 2, 0), newPotion.baseName + "_EXTENDED"));
// for (ProtoPotion child : newPotionChildren.values()) {
// customPotions.put(child, new HashMap<>());
// }
// customPotions.put(newPotion, newPotionChildren);
// newPotion = new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.HUNGER, (int) (900 * mod), 0), "HUNGER");
// newPotionChildren = new HashMap<>();
// newPotionChildren.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() / 2, 1), newPotion.baseName + "_II"));
// newPotionChildren.put(new Ingredient(Material.REDSTONE), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() * 2, 0), newPotion.baseName + "_EXTENDED"));
// for (ProtoPotion child : newPotionChildren.values()) {
// customPotions.put(child, new HashMap<>());
// }
// customPotions.put(newPotion, newPotionChildren);
// newPotion = new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.WITHER, (int) (450 * mod), 0), "DECAY");
// newPotionChildren = new HashMap<>();
// newPotionChildren.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() / 2, 1), newPotion.baseName + "_II"));
// newPotionChildren.put(new Ingredient(Material.REDSTONE), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() * 2, 0), newPotion.baseName + "_EXTENDED"));
// for (ProtoPotion child : newPotionChildren.values()) {
// customPotions.put(child, new HashMap<>());
// }
// customPotions.put(newPotion, newPotionChildren);
// newPotion = new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.ABSORPTION, (int) (1800 * mod), 0), "ABSORPTION");
// newPotionChildren = new HashMap<>();
// newPotionChildren.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() / 2, 1), newPotion.baseName + "_II"));
// newPotionChildren.put(new Ingredient(Material.REDSTONE), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() * 2, 0), newPotion.baseName + "_EXTENDED"));
// for (ProtoPotion child : newPotionChildren.values()) {
// customPotions.put(child, new HashMap<>());
// }
// customPotions.put(newPotion, newPotionChildren);
// newPotion = new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.SATURATION, (int) (8 * mod), 0), "SATURATION");
// newPotionChildren = new HashMap<>();
// newPotionChildren.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() / 2, 1), newPotion.baseName + "_II"));
// newPotionChildren.put(new Ingredient(Material.REDSTONE), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() * 2, 0), newPotion.baseName + "_EXTENDED"));
// for (ProtoPotion child : newPotionChildren.values()) {
// customPotions.put(child, new HashMap<>());
// }
// customPotions.put(newPotion, newPotionChildren);
// newPotion = new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.HEALTH_BOOST, (int) (1800 * mod), 0), "HEALTH_BOOST");
// newPotionChildren = new HashMap<>();
// newPotionChildren.put(new Ingredient(Material.GLOWSTONE_DUST), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() / 2, 1), newPotion.baseName + "_II"));
// newPotionChildren.put(new Ingredient(Material.REDSTONE), new ProtoPotion(material, PotionType.UNCRAFTABLE, new PotionEffect(newPotion.effect.getType(), newPotion.effect.getDuration() * 2, 0), newPotion.baseName + "_EXTENDED"));
// for (ProtoPotion child : newPotionChildren.values()) {
// customPotions.put(child, new HashMap<>());
// }
// customPotions.put(newPotion, newPotionChildren);
// }
//
// // Add all material state changes
// for (Entry<ProtoPotion, Map<Ingredient, ProtoPotion>> entry : customPotions.entrySet()) {
// if (entry.getKey().mat == Material.POTION) {
// PotionEffect effect = new PotionEffect(entry.getKey().effect.getType(), (int) (entry.getKey().effect.getDuration() * 0.75), entry.getKey().effect.getAmplifier());
// entry.getValue().put(new Ingredient(Material.GUNPOWDER), new ProtoPotion(Material.SPLASH_POTION, entry.getKey().data, effect, entry.getKey().baseName));
// } else if (entry.getKey().mat == Material.SPLASH_POTION) {
// PotionEffect effect = new PotionEffect(entry.getKey().effect.getType(), (int) (entry.getKey().effect.getDuration() * 0.33), entry.getKey().effect.getAmplifier());
// entry.getValue().put(new Ingredient(Material.DRAGON_BREATH), new ProtoPotion(Material.LINGERING_POTION, entry.getKey().data, effect, entry.getKey().baseName));
// }
// }
// }
//
// 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 ProtoPotion {
//
// public String name;
// public Material mat;
// public PotionData data;
// public PotionEffect effect;
// public String baseName;
//
// public ProtoPotion(PotionData data) {
// this(Material.POTION, data);
// }
//
// public ProtoPotion(Material type, PotionData data) {
// this(type, data, null, getMCName(data.getType()));
// }
//
// public ProtoPotion(Material mat, PotionType type, PotionEffect effect, String baseName) {
// this(mat, new PotionData(type, false, false), effect, baseName);
// }
//
// public ProtoPotion(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 ProtoPotion(PotionType type) {
// this(new PotionData(type, false, false));
// }
//
// public ProtoPotion(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 ProtoPotion)) {
// return false;
// }
// return name.equals(((ProtoPotion) obj).name);
// }
//
// public void setChildren()
// }
//}

View File

@ -0,0 +1,170 @@
//package com.gmail.nossr50.config;
//
//import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
//import com.gmail.nossr50.skills.alchemy.PotionGenerator;
//import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
//import org.bukkit.Material;
//import org.bukkit.inventory.ItemStack;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * Eventually I'm going to delete all of our Alchemy code and rewrite it from scratch
// */
//@ConfigSerializable
//public class PotionManager {
//
// /* CONSTANTS */
// public static final String POTIONS = "Potions";
//
// /* INGREDIENTS */
// private List<ItemStack> ingredientTierOne;
// private List<ItemStack> ingredientTierTwo;
// private List<ItemStack> ingredientTierThree;
// private List<ItemStack> ingredientTierFour;
// private List<ItemStack> ingredientTierFive;
// private List<ItemStack> ingredientTierSix;
// private List<ItemStack> ingredientTierSeven;
// private List<ItemStack> ingredientTierEight;
//
// private Map<String, AlchemyPotion> potionMap = new HashMap<>();
//
// public PotionManager() {
// initIngredientLists();
// initPotionMap();
// }
//
// /**
// * I just want anyone who reads this to know
// * This entire class is an abomination
// * What you see below is a hacky solution to keep Alchemy functioning with the new config system
// * Alchemy will be rewritten, until then, this disgusting class exists.
// */
// private void initIngredientLists() {
// ingredientTierOne = new ArrayList<>();
// ingredientTierTwo = new ArrayList<>();
// ingredientTierThree = new ArrayList<>();
// ingredientTierFour = new ArrayList<>();
// ingredientTierFive = new ArrayList<>();
// ingredientTierSix = new ArrayList<>();
// ingredientTierSeven = new ArrayList<>();
// ingredientTierEight = new ArrayList<>();
//
// ingredientTierOne.add(new ItemStack(Material.BLAZE_POWDER));
// ingredientTierOne.add(new ItemStack(Material.FERMENTED_SPIDER_EYE));
// ingredientTierOne.add(new ItemStack(Material.GHAST_TEAR));
// ingredientTierOne.add(new ItemStack(Material.GLOWSTONE_DUST));
// ingredientTierOne.add(new ItemStack(Material.GOLDEN_CARROT));
// ingredientTierOne.add(new ItemStack(Material.MAGMA_CREAM));
// ingredientTierOne.add(new ItemStack(Material.NETHER_WART));
// ingredientTierOne.add(new ItemStack(Material.REDSTONE));
// ingredientTierOne.add(new ItemStack(Material.GLISTERING_MELON_SLICE));
// ingredientTierOne.add(new ItemStack(Material.SPIDER_EYE));
// ingredientTierOne.add(new ItemStack(Material.SUGAR));
// ingredientTierOne.add(new ItemStack(Material.GUNPOWDER));
// ingredientTierOne.add(new ItemStack(Material.PUFFERFISH));
// ingredientTierOne.add(new ItemStack(Material.DRAGON_BREATH));
//
// ingredientTierTwo.add(new ItemStack(Material.CARROT));
// ingredientTierTwo.add(new ItemStack(Material.SLIME_BALL));
// ingredientTierTwo.add(new ItemStack(Material.PHANTOM_MEMBRANE));
//
// ingredientTierThree.add(new ItemStack(Material.QUARTZ));
// ingredientTierThree.add(new ItemStack(Material.RED_MUSHROOM));
//
// ingredientTierFour.add(new ItemStack(Material.APPLE));
// ingredientTierFour.add(new ItemStack(Material.ROTTEN_FLESH));
//
// ingredientTierFive.add(new ItemStack(Material.BROWN_MUSHROOM));
// ingredientTierFive.add(new ItemStack(Material.INK_SAC));
//
// ingredientTierSix.add(new ItemStack(Material.FERN));
//
// ingredientTierSeven.add(new ItemStack(Material.POISONOUS_POTATO));
//
// ingredientTierEight.add(new ItemStack(Material.GOLDEN_APPLE));
// }
//
// private void loadConcoctionsTier(List<ItemStack> ingredientList, List<String> ingredients) {
// if (ingredients != null && ingredients.size() > 0) {
// for (String ingredientString : ingredients) {
// ItemStack ingredient = loadIngredient(ingredientString);
//
// if (ingredient != null) {
// ingredientList.add(ingredient);
// }
// }
// }
// }
//
// private void initPotionMap() {
// PotionGenerator potionGenerator = new PotionGenerator();
// potionMap = potionMap
// }
//
// /**
// * Parse a string representation of an ingredient.
// * Format: '&lt;MATERIAL&gt;[:data]'
// * Returns null if input cannot be parsed.
// *
// * @param ingredient String representing an ingredient.
// * @return Parsed ingredient.
// */
// private ItemStack loadIngredient(String ingredient) {
// if (ingredient == null || ingredient.isEmpty()) {
// return null;
// }
//
// Material material = Material.getMaterial(ingredient);
//
// if (material != null) {
// return new ItemStack(material, 1);
// }
//
// return null;
// }
//
// public List<ItemStack> getIngredients(int tier) {
// switch (tier) {
// case 8:
// return ingredientTierEight;
// case 7:
// return ingredientTierSeven;
// case 6:
// return ingredientTierSix;
// case 5:
// return ingredientTierFive;
// case 4:
// return ingredientTierFour;
// case 3:
// return ingredientTierThree;
// case 2:
// return ingredientTierTwo;
// case 1:
// default:
// return ingredientTierOne;
// }
// }
//
// public boolean isValidPotion(ItemStack item) {
// return getPotion(item) != null;
// }
//
// public AlchemyPotion getPotion(String name) {
// return potionMap.get(name);
// }
//
// public AlchemyPotion getPotion(ItemStack item) {
// for (AlchemyPotion potion : potionMap.values()) {
// if (potion.isSimilar(item)) {
// return potion;
// }
// }
// return null;
// }
//
//
//}

View File

@ -0,0 +1,86 @@
//package com.gmail.nossr50.datatypes.skills.alchemy;
//
//import org.bukkit.Material;
//import org.bukkit.potion.PotionData;
//import org.bukkit.potion.PotionEffect;
//import org.bukkit.potion.PotionType;
//
//import java.util.List;
//
//public enum PotionStage {
// FIVE(5),
// FOUR(4),
// THREE(3),
// TWO(2),
// ONE(1);
//
// int numerical;
//
// PotionStage(int numerical) {
// this.numerical = numerical;
// }
//
// private static PotionStage getPotionStageNumerical(int numerical) {
// for (PotionStage potionStage : values()) {
// if (numerical >= potionStage.toNumerical()) {
// return potionStage;
// }
// }
//
// return ONE;
// }
//
// public static PotionStage getPotionStage(AlchemyPotion input, AlchemyPotion output) {
// PotionStage potionStage = getPotionStage(output);
// if (!isWaterBottle(input) && getPotionStage(input) == potionStage) {
// potionStage = PotionStage.FIVE;
// }
//
// return potionStage;
// }
//
// private static boolean isWaterBottle(AlchemyPotion input) {
// return input.getData().getType() == PotionType.WATER;
// }
//
// public static PotionStage getPotionStage(AlchemyPotion alchemyPotion) {
// PotionData data = alchemyPotion.getData();
// List<PotionEffect> effects = alchemyPotion.getEffects();
//
// int stage = 1;
//
// // Check if potion has an effect of any sort
// if (data.getType().getEffectType() != null || !effects.isEmpty()) {
// stage++;
// }
//
// // Check if potion has a glowstone dust amplifier
// // Else check if the potion has a custom effect with an amplifier added by mcMMO
// if (data.isUpgraded()) {
// stage++;
// } else if (!effects.isEmpty()) {
// for (PotionEffect effect : effects) {
// if (effect.getAmplifier() > 0) {
// stage++;
// break;
// }
// }
// }
//
// // Check if potion has a redstone dust amplifier
// if (data.isExtended()) {
// stage++;
// }
//
// // Check if potion has a gunpowder amplifier
// if (alchemyPotion.getMaterial() == Material.SPLASH_POTION || alchemyPotion.getMaterial() == Material.LINGERING_POTION) {
// stage++;
// }
//
// return PotionStage.getPotionStageNumerical(stage);
// }
//
// public int toNumerical() {
// return numerical;
// }
//}