mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-25 16:45:28 +02:00
optimizations
This commit is contained in:
@@ -38,11 +38,19 @@ public final class BlockUtils {
|
||||
* @param blockState target blockstate
|
||||
* @param triple marks the block to give triple drops
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "2.2.024")
|
||||
public static void markDropsAsBonus(BlockState blockState, boolean triple) {
|
||||
if (triple)
|
||||
blockState.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(2, mcMMO.p));
|
||||
blockState.getBlock().setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(2, mcMMO.p));
|
||||
else
|
||||
blockState.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(1, mcMMO.p));
|
||||
blockState.getBlock().setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(1, mcMMO.p));
|
||||
}
|
||||
|
||||
public static void markDropsAsBonus(Block block, boolean triple) {
|
||||
if (triple)
|
||||
block.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(2, mcMMO.p));
|
||||
else
|
||||
block.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(1, mcMMO.p));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,10 +98,20 @@ public final class BlockUtils {
|
||||
* @param blockState target blockstate
|
||||
* @param amount amount of extra items to drop
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "2.2.024")
|
||||
public static void markDropsAsBonus(BlockState blockState, int amount) {
|
||||
blockState.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(amount, mcMMO.p));
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks a block to drop extra copies of items
|
||||
* @param block target block
|
||||
* @param amount the number of extra items to drop
|
||||
*/
|
||||
public static void markDropsAsBonus(Block block, int amount) {
|
||||
block.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(amount, mcMMO.p));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player successfully passed the double drop check
|
||||
*
|
||||
@@ -114,6 +132,7 @@ public final class BlockUtils {
|
||||
* @param subSkillType the subskill involved
|
||||
* @return true if the player succeeded in the check
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "2.2.024")
|
||||
public static boolean checkDoubleDrops(@Nullable McMMOPlayer mmoPlayer, @NotNull BlockState blockState,
|
||||
@NotNull SubSkillType subSkillType) {
|
||||
requireNonNull(blockState, "blockState cannot be null");
|
||||
@@ -126,6 +145,25 @@ public final class BlockUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player successfully passed the double drop check
|
||||
* @param mmoPlayer the player involved in the check
|
||||
* @param block the block
|
||||
* @param subSkillType the subskill involved
|
||||
* @return true if the player succeeded in the check
|
||||
*/
|
||||
public static boolean checkDoubleDrops(@Nullable McMMOPlayer mmoPlayer, @NotNull Block block,
|
||||
@NotNull SubSkillType subSkillType) {
|
||||
requireNonNull(block, "block cannot be null");
|
||||
requireNonNull(subSkillType, "subSkillType cannot be null");
|
||||
if (mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(subSkillType.getParentSkill(), block.getType())
|
||||
&& Permissions.isSubSkillEnabled(mmoPlayer, subSkillType)) {
|
||||
return ProbabilityUtil.isSkillRNGSuccessful(subSkillType, mmoPlayer);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a given block awards XP.
|
||||
*
|
||||
@@ -133,11 +171,18 @@ public final class BlockUtils {
|
||||
* @return true if the block awards XP, false otherwise
|
||||
*/
|
||||
public static boolean shouldBeWatched(BlockState blockState) {
|
||||
return affectedByGigaDrillBreaker(blockState) || affectedByGreenTerra(blockState) || affectedBySuperBreaker(blockState) || hasWoodcuttingXP(blockState)
|
||||
|| mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.MINING, blockState.getType())
|
||||
|| mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.EXCAVATION, blockState.getType())
|
||||
|| mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, blockState.getType())
|
||||
|| mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.SMELTING, blockState.getType());
|
||||
return shouldBeWatched(blockState.getType());
|
||||
}
|
||||
|
||||
public static boolean shouldBeWatched(Material material) {
|
||||
return affectedByGigaDrillBreaker(material)
|
||||
|| affectedByGreenTerra(material)
|
||||
|| affectedBySuperBreaker(material)
|
||||
|| hasWoodcuttingXP(material)
|
||||
|| mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.MINING, material)
|
||||
|| mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.EXCAVATION, material)
|
||||
|| mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, material)
|
||||
|| mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.SMELTING, material);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,10 +192,15 @@ public final class BlockUtils {
|
||||
* @return true if the block should allow ability activation, false
|
||||
* otherwise
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "2.2.024")
|
||||
public static boolean canActivateAbilities(BlockState blockState) {
|
||||
return !mcMMO.getMaterialMapStore().isAbilityActivationBlackListed(blockState.getType());
|
||||
}
|
||||
|
||||
public static boolean canActivateAbilities(Block block) {
|
||||
return !mcMMO.getMaterialMapStore().isAbilityActivationBlackListed(block.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given block should allow for the activation of tools
|
||||
* Activating a tool is step 1 of a 2 step process for super ability activation
|
||||
@@ -172,7 +222,25 @@ public final class BlockUtils {
|
||||
* @return true if the block is an ore, false otherwise
|
||||
*/
|
||||
public static boolean isOre(BlockState blockState) {
|
||||
return MaterialUtils.isOre(blockState.getType());
|
||||
return isOre(blockState.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given block is an ore
|
||||
* @param block The {@link Block} to check
|
||||
* @return true if the block is an ore, false otherwise
|
||||
*/
|
||||
public static boolean isOre(Block block) {
|
||||
return isOre(block.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given material is an ore
|
||||
* @param material The {@link Material} to check
|
||||
* @return true if the material is an ore, false otherwise
|
||||
*/
|
||||
public static boolean isOre(Material material) {
|
||||
return MaterialUtils.isOre(material);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,10 +249,15 @@ public final class BlockUtils {
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
* @return true if the block can be made mossy, false otherwise
|
||||
*/
|
||||
@Deprecated(since = "2.2.024")
|
||||
public static boolean canMakeMossy(BlockState blockState) {
|
||||
return mcMMO.getMaterialMapStore().isMossyWhiteListed(blockState.getType());
|
||||
}
|
||||
|
||||
public static boolean canMakeMossy(Block block) {
|
||||
return mcMMO.getMaterialMapStore().isMossyWhiteListed(block.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a given block should be affected by Green Terra
|
||||
*
|
||||
@@ -192,41 +265,56 @@ public final class BlockUtils {
|
||||
* @return true if the block should affected by Green Terra, false otherwise
|
||||
*/
|
||||
public static boolean affectedByGreenTerra(BlockState blockState) {
|
||||
if (ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.HERBALISM, blockState.getBlockData())) {
|
||||
return true;
|
||||
}
|
||||
return affectedByGreenTerra(blockState.getType());
|
||||
}
|
||||
|
||||
return mcMMO.getModManager().isCustomHerbalismBlock(blockState);
|
||||
public static boolean affectedByGreenTerra(Block block) {
|
||||
return affectedByGreenTerra(block.getType());
|
||||
}
|
||||
|
||||
public static boolean affectedByGreenTerra(Material material) {
|
||||
return ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.HERBALISM, material);
|
||||
}
|
||||
|
||||
public static boolean affectedBySuperBreaker(BlockState blockState) {
|
||||
return affectedBySuperBreaker(blockState.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a given block should be affected by Super Breaker
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
* @param block The {@link Block} to check
|
||||
* @return true if the block should affected by Super Breaker, false
|
||||
* otherwise
|
||||
*/
|
||||
public static boolean affectedBySuperBreaker(BlockState blockState) {
|
||||
if (mcMMO.getMaterialMapStore().isIntendedToolPickaxe(blockState.getType()))
|
||||
public static boolean affectedBySuperBreaker(Block block) {
|
||||
return affectedBySuperBreaker(block.getType());
|
||||
}
|
||||
|
||||
public static boolean affectedBySuperBreaker(Material material) {
|
||||
if (mcMMO.getMaterialMapStore().isIntendedToolPickaxe(material))
|
||||
return true;
|
||||
|
||||
if (ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.MINING, blockState.getBlockData()))
|
||||
return true;
|
||||
|
||||
return mcMMO.getModManager().isCustomMiningBlock(blockState);
|
||||
return ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.MINING, material);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a given block should be affected by Giga Drill Breaker
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
* @return true if the block should affected by Giga Drill Breaker, false
|
||||
* @return true if the block should be affected by Giga Drill Breaker, false
|
||||
* otherwise
|
||||
*/
|
||||
public static boolean affectedByGigaDrillBreaker(@NotNull BlockState blockState) {
|
||||
if (ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.EXCAVATION, blockState.getBlockData()))
|
||||
return true;
|
||||
return mcMMO.getModManager().isCustomExcavationBlock(blockState);
|
||||
return affectedByGigaDrillBreaker(blockState.getType());
|
||||
}
|
||||
|
||||
public static boolean affectedByGigaDrillBreaker(@NotNull Block block) {
|
||||
return affectedByGigaDrillBreaker(block.getType());
|
||||
}
|
||||
|
||||
public static boolean affectedByGigaDrillBreaker(@NotNull Material material) {
|
||||
return ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.EXCAVATION, material);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,7 +324,15 @@ public final class BlockUtils {
|
||||
* @return true if the block is a log, false otherwise
|
||||
*/
|
||||
public static boolean hasWoodcuttingXP(@NotNull BlockState blockState) {
|
||||
return ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.WOODCUTTING, blockState.getBlockData());
|
||||
return hasWoodcuttingXP(blockState.getType());
|
||||
}
|
||||
|
||||
public static boolean hasWoodcuttingXP(@NotNull Block block) {
|
||||
return hasWoodcuttingXP(block.getType());
|
||||
}
|
||||
|
||||
public static boolean hasWoodcuttingXP(@NotNull Material material) {
|
||||
return ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.WOODCUTTING, material);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,7 +342,11 @@ public final class BlockUtils {
|
||||
* @return true if the block is a leaf, false otherwise
|
||||
*/
|
||||
public static boolean isNonWoodPartOfTree(@NotNull BlockState blockState) {
|
||||
return mcMMO.getMaterialMapStore().isTreeFellerDestructible(blockState.getType());
|
||||
return isNonWoodPartOfTree(blockState.getType());
|
||||
}
|
||||
|
||||
public static boolean isNonWoodPartOfTree(@NotNull Block block) {
|
||||
return isNonWoodPartOfTree(block.getType());
|
||||
}
|
||||
|
||||
public static boolean isNonWoodPartOfTree(@NotNull Material material) {
|
||||
@@ -289,7 +389,15 @@ public final class BlockUtils {
|
||||
* otherwise
|
||||
*/
|
||||
public static boolean affectedByBlockCracker(BlockState blockState) {
|
||||
return mcMMO.getMaterialMapStore().isBlockCrackerWhiteListed(blockState.getType());
|
||||
return affectedByBlockCracker(blockState.getType());
|
||||
}
|
||||
|
||||
public static boolean affectedByBlockCracker(Block block) {
|
||||
return affectedByBlockCracker(block.getType());
|
||||
}
|
||||
|
||||
public static boolean affectedByBlockCracker(Material material) {
|
||||
return mcMMO.getMaterialMapStore().isBlockCrackerWhiteListed(material);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -35,7 +36,10 @@ public final class Misc {
|
||||
public static final float LEVELUP_PITCH = 0.5F; // Reduced to differentiate between vanilla level-up
|
||||
public static final float LEVELUP_VOLUME = 0.75F * Config.getInstance().getMasterVolume(); // Use max volume always*/
|
||||
|
||||
public static final @NotNull Set<String> modNames = ImmutableSet.of("LOTR", "BUILDCRAFT", "ENDERIO", "ENHANCEDBIOMES", "IC2", "METALLURGY", "FORESTRY", "GALACTICRAFT", "RAILCRAFT", "TWILIGHTFOREST", "THAUMCRAFT", "GRAVESTONEMOD", "GROWTHCRAFT", "ARCTICMOBS", "DEMONMOBS", "INFERNOMOBS", "SWAMPMOBS", "MARICULTURE", "MINESTRAPPOLATION");
|
||||
public static final @NotNull Set<String> modNames = ImmutableSet.of("LOTR", "BUILDCRAFT", "ENDERIO",
|
||||
"ENHANCEDBIOMES", "IC2", "METALLURGY", "FORESTRY", "GALACTICRAFT", "RAILCRAFT", "TWILIGHTFOREST",
|
||||
"THAUMCRAFT", "GRAVESTONEMOD", "GROWTHCRAFT", "ARCTICMOBS", "DEMONMOBS", "INFERNOMOBS", "SWAMPMOBS",
|
||||
"MARICULTURE", "MINESTRAPPOLATION");
|
||||
|
||||
private Misc() {}
|
||||
|
||||
@@ -97,7 +101,15 @@ public final class Misc {
|
||||
* @return A {@link Location} lying at the center of the block
|
||||
*/
|
||||
public static Location getBlockCenter(BlockState blockState) {
|
||||
return blockState.getLocation().add(0.5, 0.5, 0.5);
|
||||
return getBlockCenter(blockState.getLocation());
|
||||
}
|
||||
|
||||
public static Location getBlockCenter(Block block) {
|
||||
return getBlockCenter(block.getLocation());
|
||||
}
|
||||
|
||||
public static Location getBlockCenter(Location location) {
|
||||
return location.add(0.5, 0.5, 0.5);
|
||||
}
|
||||
|
||||
public static void profileCleanup(@NotNull String playerName) {
|
||||
@@ -111,7 +123,9 @@ public final class Misc {
|
||||
|
||||
public static void printProgress(int convertedUsers, int progressInterval, long startMillis) {
|
||||
if ((convertedUsers % progressInterval) == 0) {
|
||||
mcMMO.p.getLogger().info(String.format("Conversion progress: %d users at %.2f users/second", convertedUsers, convertedUsers / (double) ((System.currentTimeMillis() - startMillis) / TIME_CONVERSION_FACTOR)));
|
||||
mcMMO.p.getLogger().info(String.format("Conversion progress: %d users at %.2f users/second",
|
||||
convertedUsers,
|
||||
convertedUsers / (double) ((System.currentTimeMillis() - startMillis) / TIME_CONVERSION_FACTOR)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,275 +1,275 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import com.gmail.nossr50.config.mods.CustomArmorLegacyConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomBlockLegacyConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomEntityLegacyConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolLegacyConfig;
|
||||
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 final List<Repairable> repairables = new ArrayList<>();
|
||||
|
||||
// Armor Mods
|
||||
private final List<Material> customBoots = new ArrayList<>();
|
||||
private final List<Material> customChestplates = new ArrayList<>();
|
||||
private final List<Material> customHelmets = new ArrayList<>();
|
||||
private final List<Material> customLeggings = new ArrayList<>();
|
||||
|
||||
// Block Mods
|
||||
private final List<Material> customExcavationBlocks = new ArrayList<>();
|
||||
private final List<Material> customHerbalismBlocks = new ArrayList<>();
|
||||
private final List<Material> customMiningBlocks = new ArrayList<>();
|
||||
private final List<Material> customOres = new ArrayList<>();
|
||||
private final List<Material> customLogs = new ArrayList<>();
|
||||
private final List<Material> customLeaves = new ArrayList<>();
|
||||
private final List<Material> customAbilityBlocks = new ArrayList<>();
|
||||
private final HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
|
||||
|
||||
// Entity Mods
|
||||
private final HashMap<String, CustomEntity> customEntityClassMap = new HashMap<>();
|
||||
private final HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<>();
|
||||
|
||||
// Tool Mods
|
||||
private final List<Material> customAxes = new ArrayList<>();
|
||||
private final List<Material> customBows = new ArrayList<>();
|
||||
private final List<Material> customHoes = new ArrayList<>();
|
||||
private final List<Material> customPickaxes = new ArrayList<>();
|
||||
private final List<Material> customShovels = new ArrayList<>();
|
||||
private final List<Material> customSwords = new ArrayList<>();
|
||||
private final HashMap<Material, CustomTool> customToolMap = new HashMap<>();
|
||||
|
||||
public void registerCustomArmor(CustomArmorLegacyConfig config) {
|
||||
customBoots.addAll(config.customBoots);
|
||||
customChestplates.addAll(config.customChestplates);
|
||||
customHelmets.addAll(config.customHelmets);
|
||||
customLeggings.addAll(config.customLeggings);
|
||||
repairables.addAll(config.repairables);
|
||||
}
|
||||
|
||||
public void registerCustomBlocks(CustomBlockLegacyConfig 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(CustomEntityLegacyConfig config) {
|
||||
customEntityClassMap.putAll(config.customEntityClassMap);
|
||||
customEntityTypeMap.putAll(config.customEntityTypeMap);
|
||||
}
|
||||
|
||||
public void registerCustomTools(CustomToolLegacyConfig 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 mcMMO.p.getGeneralConfig().getArmorModsEnabled() && customBoots.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomChestplate(Material material) {
|
||||
return mcMMO.p.getGeneralConfig().getArmorModsEnabled() && customChestplates.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomHelmet(Material material) {
|
||||
return mcMMO.p.getGeneralConfig().getArmorModsEnabled() && customHelmets.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomLeggings(Material material) {
|
||||
return mcMMO.p.getGeneralConfig().getArmorModsEnabled() && customLeggings.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomAxe(Material material) {
|
||||
return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customAxes.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomBow(Material material) {
|
||||
return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customBows.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomHoe(Material material) {
|
||||
return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customHoes.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomPickaxe(Material material) {
|
||||
return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customPickaxes.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomShovel(Material material) {
|
||||
return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customShovels.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomSword(Material material) {
|
||||
return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customSwords.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomOre(Material data) {
|
||||
return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customOres.contains(data);
|
||||
}
|
||||
|
||||
public boolean isCustomLog(BlockState state) {
|
||||
return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customLogs.contains(state.getType());
|
||||
}
|
||||
|
||||
public boolean isCustomAbilityBlock(BlockState state) {
|
||||
return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customAbilityBlocks.contains(state.getType());
|
||||
}
|
||||
|
||||
public boolean isCustomExcavationBlock(BlockState state) {
|
||||
return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customExcavationBlocks.contains(state.getType());
|
||||
}
|
||||
|
||||
public boolean isCustomHerbalismBlock(BlockState state) {
|
||||
return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customHerbalismBlocks.contains(state.getType());
|
||||
}
|
||||
|
||||
public boolean isCustomMiningBlock(BlockState state) {
|
||||
return mcMMO.p.getGeneralConfig().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 mcMMO.p.getGeneralConfig().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 (!mcMMO.p.getGeneralConfig().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 (!mcMMO.p.getGeneralConfig().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);
|
||||
LogUtils.debug(mcMMO.p.getLogger(), entity.getType().toString() + " was added to the custom entities file!");
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.util;
|
||||
//
|
||||
//import com.gmail.nossr50.config.mods.CustomArmorLegacyConfig;
|
||||
//import com.gmail.nossr50.config.mods.CustomBlockLegacyConfig;
|
||||
//import com.gmail.nossr50.config.mods.CustomEntityLegacyConfig;
|
||||
//import com.gmail.nossr50.config.mods.CustomToolLegacyConfig;
|
||||
//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 final List<Repairable> repairables = new ArrayList<>();
|
||||
//
|
||||
// // Armor Mods
|
||||
// private final List<Material> customBoots = new ArrayList<>();
|
||||
// private final List<Material> customChestplates = new ArrayList<>();
|
||||
// private final List<Material> customHelmets = new ArrayList<>();
|
||||
// private final List<Material> customLeggings = new ArrayList<>();
|
||||
//
|
||||
// // Block Mods
|
||||
// private final List<Material> customExcavationBlocks = new ArrayList<>();
|
||||
// private final List<Material> customHerbalismBlocks = new ArrayList<>();
|
||||
// private final List<Material> customMiningBlocks = new ArrayList<>();
|
||||
// private final List<Material> customOres = new ArrayList<>();
|
||||
// private final List<Material> customLogs = new ArrayList<>();
|
||||
// private final List<Material> customLeaves = new ArrayList<>();
|
||||
// private final List<Material> customAbilityBlocks = new ArrayList<>();
|
||||
// private final HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
|
||||
//
|
||||
// // Entity Mods
|
||||
// private final HashMap<String, CustomEntity> customEntityClassMap = new HashMap<>();
|
||||
// private final HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<>();
|
||||
//
|
||||
// // Tool Mods
|
||||
// private final List<Material> customAxes = new ArrayList<>();
|
||||
// private final List<Material> customBows = new ArrayList<>();
|
||||
// private final List<Material> customHoes = new ArrayList<>();
|
||||
// private final List<Material> customPickaxes = new ArrayList<>();
|
||||
// private final List<Material> customShovels = new ArrayList<>();
|
||||
// private final List<Material> customSwords = new ArrayList<>();
|
||||
// private final HashMap<Material, CustomTool> customToolMap = new HashMap<>();
|
||||
//
|
||||
// public void registerCustomArmor(CustomArmorLegacyConfig config) {
|
||||
// customBoots.addAll(config.customBoots);
|
||||
// customChestplates.addAll(config.customChestplates);
|
||||
// customHelmets.addAll(config.customHelmets);
|
||||
// customLeggings.addAll(config.customLeggings);
|
||||
// repairables.addAll(config.repairables);
|
||||
// }
|
||||
//
|
||||
// public void registerCustomBlocks(CustomBlockLegacyConfig 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(CustomEntityLegacyConfig config) {
|
||||
// customEntityClassMap.putAll(config.customEntityClassMap);
|
||||
// customEntityTypeMap.putAll(config.customEntityTypeMap);
|
||||
// }
|
||||
//
|
||||
// public void registerCustomTools(CustomToolLegacyConfig 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 mcMMO.p.getGeneralConfig().getArmorModsEnabled() && customBoots.contains(material);
|
||||
// }
|
||||
//
|
||||
// public boolean isCustomChestplate(Material material) {
|
||||
// return mcMMO.p.getGeneralConfig().getArmorModsEnabled() && customChestplates.contains(material);
|
||||
// }
|
||||
//
|
||||
// public boolean isCustomHelmet(Material material) {
|
||||
// return mcMMO.p.getGeneralConfig().getArmorModsEnabled() && customHelmets.contains(material);
|
||||
// }
|
||||
//
|
||||
// public boolean isCustomLeggings(Material material) {
|
||||
// return mcMMO.p.getGeneralConfig().getArmorModsEnabled() && customLeggings.contains(material);
|
||||
// }
|
||||
//
|
||||
// public boolean isCustomAxe(Material material) {
|
||||
// return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customAxes.contains(material);
|
||||
// }
|
||||
//
|
||||
// public boolean isCustomBow(Material material) {
|
||||
// return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customBows.contains(material);
|
||||
// }
|
||||
//
|
||||
// public boolean isCustomHoe(Material material) {
|
||||
// return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customHoes.contains(material);
|
||||
// }
|
||||
//
|
||||
// public boolean isCustomPickaxe(Material material) {
|
||||
// return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customPickaxes.contains(material);
|
||||
// }
|
||||
//
|
||||
// public boolean isCustomShovel(Material material) {
|
||||
// return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customShovels.contains(material);
|
||||
// }
|
||||
//
|
||||
// public boolean isCustomSword(Material material) {
|
||||
// return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customSwords.contains(material);
|
||||
// }
|
||||
//
|
||||
// public boolean isCustomOre(Material data) {
|
||||
// return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customOres.contains(data);
|
||||
// }
|
||||
//
|
||||
// public boolean isCustomLog(BlockState state) {
|
||||
// return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customLogs.contains(state.getType());
|
||||
// }
|
||||
//
|
||||
// public boolean isCustomAbilityBlock(BlockState state) {
|
||||
// return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customAbilityBlocks.contains(state.getType());
|
||||
// }
|
||||
//
|
||||
// public boolean isCustomExcavationBlock(BlockState state) {
|
||||
// return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customExcavationBlocks.contains(state.getType());
|
||||
// }
|
||||
//
|
||||
// public boolean isCustomHerbalismBlock(BlockState state) {
|
||||
// return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customHerbalismBlocks.contains(state.getType());
|
||||
// }
|
||||
//
|
||||
// public boolean isCustomMiningBlock(BlockState state) {
|
||||
// return mcMMO.p.getGeneralConfig().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 mcMMO.p.getGeneralConfig().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 (!mcMMO.p.getGeneralConfig().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 (!mcMMO.p.getGeneralConfig().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);
|
||||
// LogUtils.debug(mcMMO.p.getLogger(), entity.getType().toString() + " was added to the custom entities file!");
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@@ -313,15 +313,6 @@ public final class CommandRegistrationManager {
|
||||
command.setExecutor(new McscoreboardCommand());
|
||||
}
|
||||
|
||||
private static void registerMcImportCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcimport");
|
||||
command.setDescription("Import mod config files"); //TODO: Localize
|
||||
command.setPermission("mcmmo.commands.mcimport");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcimport"));
|
||||
command.setExecutor(new McImportCommand());
|
||||
}
|
||||
|
||||
private static void registerReloadLocaleCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcmmoreloadlocale");
|
||||
command.setDescription("Reloads locale"); // TODO: Localize
|
||||
@@ -351,7 +342,6 @@ public final class CommandRegistrationManager {
|
||||
registerXPBarCommand();
|
||||
registerMmoInfoCommand();
|
||||
registerMmoDebugCommand();
|
||||
registerMcImportCommand();
|
||||
registerMcabilityCommand();
|
||||
registerMcgodCommand();
|
||||
registerMcChatSpyCommand();
|
||||
|
@@ -898,9 +898,7 @@ public final class CombatUtils {
|
||||
baseXP = 20 * ExperienceConfig.getInstance().getPlayerVersusPlayerXP();
|
||||
}
|
||||
} else {
|
||||
if (mcMMO.getModManager().isCustomEntity(target)) {
|
||||
baseXP = mcMMO.getModManager().getEntity(target).getXpMultiplier();
|
||||
} else if (target instanceof Animals) {
|
||||
if (target instanceof Animals) {
|
||||
EntityType type = target.getType();
|
||||
baseXP = ExperienceConfig.getInstance().getAnimalsXP(type);
|
||||
} else if (target instanceof Monster) {
|
||||
@@ -919,7 +917,6 @@ public final class CombatUtils {
|
||||
}
|
||||
} else {
|
||||
baseXP = 1.0;
|
||||
mcMMO.getModManager().addCustomEntity(target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1046,8 +1043,6 @@ public final class CombatUtils {
|
||||
tier = 4;
|
||||
} else if (ItemUtils.isNetheriteTool(inHand)) {
|
||||
tier = 5;
|
||||
} else if (mcMMO.getModManager().isCustomTool(inHand)) {
|
||||
tier = mcMMO.getModManager().getTool(inHand).getTier();
|
||||
}
|
||||
|
||||
return tier;
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.util.text;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -11,7 +10,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static com.gmail.nossr50.util.text.StringUtils.getCapitalized;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Utility class for String operations, including formatting and caching deterministic results to improve performance.
|
||||
@@ -22,15 +20,8 @@ public class ConfigStringUtils {
|
||||
|
||||
// Using concurrent hash maps to avoid concurrency issues (Folia)
|
||||
private static final Map<EntityType, String> configEntityStrings = new ConcurrentHashMap<>();
|
||||
private static final Map<SuperAbilityType, String> configSuperAbilityStrings = new ConcurrentHashMap<>();
|
||||
private static final Map<Material, String> configMaterialStrings = new ConcurrentHashMap<>();
|
||||
private static final Map<PartyFeature, String> configPartyFeatureStrings = new ConcurrentHashMap<>();
|
||||
|
||||
public static String getConfigSuperAbilityString(SuperAbilityType superAbilityType) {
|
||||
requireNonNull(superAbilityType, "superAbilityType cannot be null");
|
||||
return configSuperAbilityStrings.computeIfAbsent(superAbilityType,
|
||||
ConfigStringUtils::createConfigFriendlyString);
|
||||
}
|
||||
|
||||
public static String getMaterialConfigString(Material material) {
|
||||
return configMaterialStrings.computeIfAbsent(material, ConfigStringUtils::createConfigFriendlyString);
|
||||
|
Reference in New Issue
Block a user