From b371e3b16926beb1fc908b0b7a3a3249afd567b3 Mon Sep 17 00:00:00 2001 From: Ceikry Date: Thu, 1 Jul 2021 22:46:25 +0000 Subject: [PATCH] Fix bonegrinder --- .../java/core/game/content/global/Bones.java | 152 ------------------ .../java/core/game/content/global/Bones.kt | 146 +++++++++++++++++ 2 files changed, 146 insertions(+), 152 deletions(-) delete mode 100644 Server/src/main/java/core/game/content/global/Bones.java create mode 100644 Server/src/main/java/core/game/content/global/Bones.kt diff --git a/Server/src/main/java/core/game/content/global/Bones.java b/Server/src/main/java/core/game/content/global/Bones.java deleted file mode 100644 index fc29a2b64..000000000 --- a/Server/src/main/java/core/game/content/global/Bones.java +++ /dev/null @@ -1,152 +0,0 @@ -package core.game.content.global; - -import core.game.node.item.Item; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -/** - * Represents the type of bones. - * @author Apache Ah64 - */ -public enum Bones { - - BONES(2530, 4.5), - BONES_2(526,4.5), - WOLF_BONES(2859, 4.5), - BURNST_BONES(528, 4.5), - MONKEY_BONES(3183, 5), - MONKEY_BONES2(3179, 5), - BAT_BONES(530, 5.3), - BIG_BONES(532, 15), - JOGRE_BONES(3125, 15), - ZOGRE_BONES(4812, 12.5), - SHAIKAHAN_BONES(3123, 25), - BABY_DRAGON_BONES(534, 30), - WYVERN_BONES(6812, 50), - DRAGON_BONES(536, 72), - FAYRG(4830, 84), - RAURG_BONES(4832, 96), - DAGANNOTH(6729, 125), - OURG_BONES(4834, 140), - LAVA_DRAGON_BONES(14693, 85); - - /** - * Holds all bones. - */ - private static HashMap bones = new HashMap(); - - - /** - * The bone item id. - */ - private int itemId; - - /** - * The experience given by burying the bone. - */ - private double experience; - - /** - * Construct a new {@code Bones} {@code Object}. - * @param itemId The item id. - * @param experience The experience given by burying the bone. - */ - private Bones(int itemId, double experience) { - this.itemId = itemId; - this.experience = experience; - } - - /** - * Gets the bone meal item. - * @return the item. - */ - public Item getBoneMeal() { - return new Item(4255 + ordinal()); - } - - /** - * Get the bone experience given when you bury the bone. - * @return The experience. - */ - public double getExperience() { - return experience; - } - - public int getItemId() { - return itemId; - } - - /** - * Gets the bones for the bone meal. - * @param itemId the item. - * @return the bones. - */ - public static Bones forBoneMeal(int itemId) { - for (Bones bone : Bones.values()) { - if (bone.getBoneMeal().getId() == itemId) { - return bone; - } - } - return null; - } - - /** - * Gets the config value for the bone. - * @param value the value. - * @param hopper hopper. - * @return {@code True} if so. - */ - public static Bones forConfigValue(int value, boolean hopper) { - for (Bones bone : Bones.values()) { - if (bone.getConfigValue(hopper) == value) { - return bone; - } - } - return null; - } - - /** - * Gets the config value for the bone type. - * @param hopper the hopper. - * @return the value. - */ - public int getConfigValue(boolean hopper) { - return (this == BONES_2 ? ordinal() : ordinal() - 1) | (hopper ? 4 : 8) << 16; - } - - /** - * Gets the bone ids. - * @return the ids. - */ - public static int[] getArray() { - List list = new ArrayList<>(20); - for (int i : bones.keySet()) { - list.add(i); - } - int[] array = new int[list.size()]; - for (int i = 0; i < list.size(); i++) { - array[i] = list.get(i); - } - return array; - } - - /** - * Get the bone. - * @param itemId The item id. - * @return The bone. - */ - public static Bones forId(int itemId) { - return bones.get(itemId); - } - - /** - * Construct the bones. - */ - static { - for (Bones bone : Bones.values()) { - bones.put(bone.itemId, bone); - } - } -} \ No newline at end of file diff --git a/Server/src/main/java/core/game/content/global/Bones.kt b/Server/src/main/java/core/game/content/global/Bones.kt new file mode 100644 index 000000000..8bdb2f183 --- /dev/null +++ b/Server/src/main/java/core/game/content/global/Bones.kt @@ -0,0 +1,146 @@ +package core.game.content.global + +import core.game.content.global.Bones +import core.game.node.item.Item +import java.util.ArrayList +import java.util.HashMap + +/** + * Represents the type of bones. + * @author Apache Ah64 + */ +enum class Bones +/** + * Construct a new `Bones` `Object`. + * @param itemId The item id. + * @param experience The experience given by burying the bone. + */( + /** + * The bone item id. + */ + val itemId: Int, + /** + * The experience given by burying the bone. + */ + val experience: Double) { + BONES(2530, 4.5), + BONES_2(526, 4.5), + WOLF_BONES(2859, 4.5), + BURNST_BONES(528, 4.5), + MONKEY_BONES(3183, 5.0), + MONKEY_BONES2(3179, 5.0), + BAT_BONES(530, 5.3), + BIG_BONES(532, 15.0), + JOGRE_BONES(3125, 15.0), + ZOGRE_BONES(4812, 12.5), + SHAIKAHAN_BONES(3123, 25.0), + BABY_DRAGON_BONES(534, 30.0), + WYVERN_BONES(6812, 50.0), + DRAGON_BONES(536, 72.0), + FAYRG(4830, 84.0), + RAURG_BONES(4832, 96.0), + DAGANNOTH(6729, 125.0), + OURG_BONES(4834, 140.0), + LAVA_DRAGON_BONES(14693, 85.0); + /** + * Get the bone experience given when you bury the bone. + * @return The experience. + */ + + /** + * Gets the bone meal item. + * @return the item. + */ + val boneMeal: Item + get() { + return when(this){ + FAYRG -> Item(4852) + RAURG_BONES -> Item(4853) + OURG_BONES -> Item(4854) + else -> Item(4255 + ordinal) + } + } + + /** + * Gets the config value for the bone type. + * @param hopper the hopper. + * @return the value. + */ + fun getConfigValue(hopper: Boolean): Int { + return (if (this == BONES_2) ordinal else ordinal - 1) or (if (hopper) 4 else 8) shl 16 + } + + companion object { + /** + * Holds all bones. + */ + private val bones = HashMap() + + /** + * Gets the bones for the bone meal. + * @param itemId the item. + * @return the bones. + */ + @JvmStatic + fun forBoneMeal(itemId: Int): Bones? { + for (bone in values()) { + if (bone.boneMeal.id == itemId) { + return bone + } + } + return null + } + + /** + * Gets the config value for the bone. + * @param value the value. + * @param hopper hopper. + * @return `True` if so. + */ + @JvmStatic + fun forConfigValue(value: Int, hopper: Boolean): Bones? { + for (bone in values()) { + if (bone.getConfigValue(hopper) == value) { + return bone + } + } + return null + } + + /** + * Gets the bone ids. + * @return the ids. + */ + val array: IntArray + @JvmStatic get() { + val list: MutableList = ArrayList(20) + for (i in bones.keys) { + list.add(i) + } + val array = IntArray(list.size) + for (i in list.indices) { + array[i] = list[i] + } + return array + } + + /** + * Get the bone. + * @param itemId The item id. + * @return The bone. + */ + @JvmStatic + fun forId(itemId: Int): Bones? { + return bones[itemId] + } + + /** + * Construct the bones. + */ + init { + for (bone in values()) { + bones[bone.itemId] = bone + } + } + } +} \ No newline at end of file