#1325: Use CraftBlockType and CraftItemType instead of CraftMagicNumbers to convert between minecraft and bukkit block / item representation
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
@@ -15,8 +15,9 @@ import net.minecraft.world.level.block.Block;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.Statistic.Type;
|
||||
import org.bukkit.craftbukkit.block.CraftBlockType;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntityType;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemType;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public enum CraftStatistic {
|
||||
@@ -147,22 +148,22 @@ public enum CraftStatistic {
|
||||
public static net.minecraft.stats.Statistic getMaterialStatistic(org.bukkit.Statistic stat, Material material) {
|
||||
try {
|
||||
if (stat == Statistic.MINE_BLOCK) {
|
||||
return StatisticList.BLOCK_MINED.get(CraftMagicNumbers.getBlock(material));
|
||||
return StatisticList.BLOCK_MINED.get(CraftBlockType.bukkitToMinecraft(material));
|
||||
}
|
||||
if (stat == Statistic.CRAFT_ITEM) {
|
||||
return StatisticList.ITEM_CRAFTED.get(CraftMagicNumbers.getItem(material));
|
||||
return StatisticList.ITEM_CRAFTED.get(CraftItemType.bukkitToMinecraft(material));
|
||||
}
|
||||
if (stat == Statistic.USE_ITEM) {
|
||||
return StatisticList.ITEM_USED.get(CraftMagicNumbers.getItem(material));
|
||||
return StatisticList.ITEM_USED.get(CraftItemType.bukkitToMinecraft(material));
|
||||
}
|
||||
if (stat == Statistic.BREAK_ITEM) {
|
||||
return StatisticList.ITEM_BROKEN.get(CraftMagicNumbers.getItem(material));
|
||||
return StatisticList.ITEM_BROKEN.get(CraftItemType.bukkitToMinecraft(material));
|
||||
}
|
||||
if (stat == Statistic.PICKUP) {
|
||||
return StatisticList.ITEM_PICKED_UP.get(CraftMagicNumbers.getItem(material));
|
||||
return StatisticList.ITEM_PICKED_UP.get(CraftItemType.bukkitToMinecraft(material));
|
||||
}
|
||||
if (stat == Statistic.DROP) {
|
||||
return StatisticList.ITEM_DROPPED.get(CraftMagicNumbers.getItem(material));
|
||||
return StatisticList.ITEM_DROPPED.get(CraftItemType.bukkitToMinecraft(material));
|
||||
}
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
return null;
|
||||
@@ -192,10 +193,10 @@ public enum CraftStatistic {
|
||||
|
||||
public static Material getMaterialFromStatistic(net.minecraft.stats.Statistic<?> statistic) {
|
||||
if (statistic.getValue() instanceof Item statisticItemValue) {
|
||||
return CraftMagicNumbers.getMaterial(statisticItemValue);
|
||||
return CraftItemType.minecraftToBukkit(statisticItemValue);
|
||||
}
|
||||
if (statistic.getValue() instanceof Block statisticBlockValue) {
|
||||
return CraftMagicNumbers.getMaterial(statisticBlockValue);
|
||||
return CraftBlockType.minecraftToBukkit(statisticBlockValue);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user