|
@@ -3,7 +3,6 @@ package com.gmail.nossr50.util;
|
|
|
import org.bukkit.block.BlockState;
|
|
|
import org.bukkit.entity.Entity;
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
-import org.bukkit.material.MaterialData;
|
|
|
|
|
|
import com.gmail.nossr50.config.Config;
|
|
|
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
|
@@ -41,19 +40,7 @@ public final class ModUtils {
|
|
|
* @return the block if it exists, null otherwise
|
|
|
*/
|
|
|
public static CustomBlock getCustomBlock(BlockState blockState) {
|
|
|
- if (customBlocksEnabled) {
|
|
|
- ItemStack item = blockState.getData().toItemStack(1);
|
|
|
-
|
|
|
- if (CustomBlockConfig.getInstance().customItems.contains(item)) {
|
|
|
- for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
|
|
- if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
|
|
- return block;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return null;
|
|
|
+ return CustomBlockConfig.getInstance().customBlockMap.get(blockState.getData());
|
|
|
}
|
|
|
|
|
|
public static CustomEntity getCustomEntity(Entity entity) {
|
|
@@ -74,22 +61,10 @@ public final class ModUtils {
|
|
|
* Check if a custom block is a woodcutting block.
|
|
|
*
|
|
|
* @param blockState The BlockState of the block to check
|
|
|
- * @return true if the block represents a log, false otherwise
|
|
|
+ * @return true if the block represents a custom woodcutting block, false otherwise
|
|
|
*/
|
|
|
public static boolean isCustomWoodcuttingBlock(BlockState blockState) {
|
|
|
- if (customBlocksEnabled) {
|
|
|
- ItemStack item = blockState.getData().toItemStack(1);
|
|
|
-
|
|
|
- if (CustomBlockConfig.getInstance().customWoodcuttingBlocks.contains(item)) {
|
|
|
- for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
|
|
- if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
+ return customBlocksEnabled && CustomBlockConfig.getInstance().customWoodcuttingBlocks.contains(blockState.getData());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -99,85 +74,37 @@ public final class ModUtils {
|
|
|
* @return true if the block represents an ability block, false otherwise
|
|
|
*/
|
|
|
public static boolean isCustomAbilityBlock(BlockState blockState) {
|
|
|
- if (customBlocksEnabled) {
|
|
|
- ItemStack item = blockState.getData().toItemStack(1);
|
|
|
-
|
|
|
- if (CustomBlockConfig.getInstance().customAbilityBlocks.contains(item)) {
|
|
|
- for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
|
|
- if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
+ return customBlocksEnabled && CustomBlockConfig.getInstance().customAbilityBlocks.contains(blockState.getData());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Check if a custom block is a mining block.
|
|
|
*
|
|
|
* @param blockState The BlockState of the block to check
|
|
|
- * @return true if the block is custom, false otherwise
|
|
|
+ * @return true if the block represents a custom mining block, false otherwise
|
|
|
*/
|
|
|
public static boolean isCustomMiningBlock(BlockState blockState) {
|
|
|
- if (customBlocksEnabled) {
|
|
|
- ItemStack item = blockState.getData().toItemStack(1);
|
|
|
-
|
|
|
- if (CustomBlockConfig.getInstance().customMiningBlocks.contains(item)) {
|
|
|
- for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
|
|
- if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
+ return customBlocksEnabled && CustomBlockConfig.getInstance().customMiningBlocks.contains(blockState.getData());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Check if a custom block is an excavation block.
|
|
|
*
|
|
|
* @param blockState The BlockState of the block to check
|
|
|
- * @return true if the block is custom, false otherwise
|
|
|
+ * @return true if the block represents a custom excavation block, false otherwise
|
|
|
*/
|
|
|
public static boolean isCustomExcavationBlock(BlockState blockState) {
|
|
|
- if (customBlocksEnabled) {
|
|
|
- ItemStack item = blockState.getData().toItemStack(1);
|
|
|
-
|
|
|
- if (CustomBlockConfig.getInstance().customExcavationBlocks.contains(item)) {
|
|
|
- for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
|
|
- if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
+ return customBlocksEnabled && CustomBlockConfig.getInstance().customExcavationBlocks.contains(blockState.getData());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Check if a custom block is an herbalism block.
|
|
|
*
|
|
|
- * @param blockState The block to check
|
|
|
- * @return true if the block is custom, false otherwise
|
|
|
+ * @param blockState The BlockState of the block to check
|
|
|
+ * @return true if the block represents a custom herbalism block, false otherwise
|
|
|
*/
|
|
|
public static boolean isCustomHerbalismBlock(BlockState blockState) {
|
|
|
- if (customBlocksEnabled) {
|
|
|
- ItemStack item = blockState.getData().toItemStack(1);
|
|
|
-
|
|
|
- if (CustomBlockConfig.getInstance().customHerbalismBlocks.contains(item)) {
|
|
|
- for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
|
|
- if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
+ return customBlocksEnabled && CustomBlockConfig.getInstance().customHerbalismBlocks.contains(blockState.getData());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -187,19 +114,7 @@ public final class ModUtils {
|
|
|
* @return true if the block represents leaves, false otherwise
|
|
|
*/
|
|
|
public static boolean isCustomLeafBlock(BlockState blockState) {
|
|
|
- if (customBlocksEnabled) {
|
|
|
- ItemStack item = blockState.getData().toItemStack(1);
|
|
|
-
|
|
|
- if (CustomBlockConfig.getInstance().customLeaves.contains(item)) {
|
|
|
- for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
|
|
- if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
+ return customBlocksEnabled && CustomBlockConfig.getInstance().customLeaves.contains(blockState.getData());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -209,41 +124,17 @@ public final class ModUtils {
|
|
|
* @return true if the block represents a log, false otherwise
|
|
|
*/
|
|
|
public static boolean isCustomLogBlock(BlockState blockState) {
|
|
|
- if (customBlocksEnabled) {
|
|
|
- ItemStack item = blockState.getData().toItemStack(1);
|
|
|
-
|
|
|
- if (CustomBlockConfig.getInstance().customLogs.contains(item)) {
|
|
|
- for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
|
|
- if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
+ return customBlocksEnabled && CustomBlockConfig.getInstance().customLogs.contains(blockState.getData());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Check if a custom block is an ore block.
|
|
|
*
|
|
|
- * @param blockState The block to check
|
|
|
+ * @param blockState The BlockState of the block to check
|
|
|
* @return true if the block represents an ore, false otherwise
|
|
|
*/
|
|
|
public static boolean isCustomOreBlock(BlockState blockState) {
|
|
|
- if (customBlocksEnabled) {
|
|
|
- ItemStack item = blockState.getData().toItemStack(1);
|
|
|
-
|
|
|
- if (CustomBlockConfig.getInstance().customOres.contains(item)) {
|
|
|
- for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
|
|
- if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
+ return customBlocksEnabled && CustomBlockConfig.getInstance().customOres.contains(blockState.getData());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -253,11 +144,7 @@ public final class ModUtils {
|
|
|
* @return true if the item is a custom tool, false otherwise
|
|
|
*/
|
|
|
public static boolean isCustomTool(ItemStack item) {
|
|
|
- if (customToolsEnabled && CustomToolConfig.getInstance().customTool.contains(item.getType())) {
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
+ return customToolsEnabled && CustomToolConfig.getInstance().customTool.contains(item.getType());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -267,19 +154,11 @@ public final class ModUtils {
|
|
|
* @return true if the item is custom armor, false otherwise
|
|
|
*/
|
|
|
public static boolean isCustomArmor(ItemStack item) {
|
|
|
- if (customArmorEnabled && CustomArmorConfig.getInstance().customArmor.contains(item.getType())) {
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
+ return customArmorEnabled && CustomArmorConfig.getInstance().customArmor.contains(item.getType());
|
|
|
}
|
|
|
|
|
|
public static boolean isCustomEntity(Entity entity) {
|
|
|
- if (customEntitiesEnabled && CustomEntityConfig.getInstance().customEntityIds.contains(entity.getEntityId())) {
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
+ return customEntitiesEnabled && CustomEntityConfig.getInstance().customEntityIds.contains(entity.getEntityId());
|
|
|
}
|
|
|
|
|
|
/**
|