Compare commits

..

9 Commits

Author SHA1 Message Date
Auxilor
83f86983f6 Updated to 6.55.4 2023-04-27 19:22:30 +01:00
Auxilor
3ba98a9a5e Fixed UltraEconomy 2023-04-27 19:22:20 +01:00
Auxilor
6ec80d30ad Updated to 6.55.3 2023-04-25 10:28:38 +01:00
Auxilor
7ccee60a0c Fixed IntegrationRegistry#executeSafely 2023-04-25 10:28:23 +01:00
Auxilor
0805b48763 Updated to 6.55.2 2023-04-24 22:12:47 +01:00
Auxilor
d737322aaa Merge remote-tracking branch 'origin/master'
# Conflicts:
#	gradle.properties
2023-04-24 22:12:19 +01:00
Auxilor
4ddc150e1c Updated to 6.54.1 2023-04-24 22:11:55 +01:00
Auxilor
0da119d89d Finally reimplemented BlockUtils#getVein 2023-04-24 22:10:42 +01:00
Auxilor
fc0a07d1c5 Config injections now use a ConcurrentHashMap 2023-04-24 22:05:37 +01:00
7 changed files with 44 additions and 41 deletions

View File

@@ -114,7 +114,7 @@ public class IntegrationRegistry<T extends Integration> extends Registry<T> {
Eco.get().getEcoPlugin().getLogger().warning("Integration for " + integration.getPluginName() + " threw an exception!"); Eco.get().getEcoPlugin().getLogger().warning("Integration for " + integration.getPluginName() + " threw an exception!");
Eco.get().getEcoPlugin().getLogger().warning("The integration will be disabled."); Eco.get().getEcoPlugin().getLogger().warning("The integration will be disabled.");
e.printStackTrace(); e.printStackTrace();
this.remove(integration.getPluginName()); this.remove(integration);
return defaultValue; return defaultValue;
} }
} }

View File

@@ -8,42 +8,15 @@ import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Queue;
import java.util.Set; import java.util.Set;
/** /**
* Utilities / API methods for blocks. * Utilities / API methods for blocks.
*/ */
public final class BlockUtils { public final class BlockUtils {
/**
* Max blocks to mine (yes, this is to prevent a stack overflow).
*/
private static final int MAX_BLOCKS = 2500;
private static Set<Block> getNearbyBlocks(@NotNull final Block start,
@NotNull final List<Material> allowedMaterials,
@NotNull final Set<Block> blocks,
final int limit) {
for (BlockFace face : BlockFace.values()) {
Block block = start.getRelative(face);
if (blocks.contains(block)) {
continue;
}
if (allowedMaterials.contains(block.getType())) {
blocks.add(block);
if (blocks.size() > limit || blocks.size() > MAX_BLOCKS) {
return blocks;
}
blocks.addAll(getNearbyBlocks(block, allowedMaterials, blocks, limit));
}
}
return blocks;
}
/** /**
* Get a set of all blocks in contact with each other of a specific type. * Get a set of all blocks in contact with each other of a specific type.
* *
@@ -56,7 +29,32 @@ public final class BlockUtils {
public static Set<Block> getVein(@NotNull final Block start, public static Set<Block> getVein(@NotNull final Block start,
@NotNull final List<Material> allowedMaterials, @NotNull final List<Material> allowedMaterials,
final int limit) { final int limit) {
return getNearbyBlocks(start, allowedMaterials, new HashSet<>(), limit); Set<Block> blocks = new HashSet<>();
Queue<Block> toProcess = new LinkedList<>();
if (allowedMaterials.contains(start.getType())) {
toProcess.add(start);
}
while (!toProcess.isEmpty() && blocks.size() < limit) {
Block currentBlock = toProcess.poll();
if (blocks.contains(currentBlock)) {
continue;
}
blocks.add(currentBlock);
for (BlockFace face : BlockFace.values()) {
Block adjacentBlock = currentBlock.getRelative(face);
if (!blocks.contains(adjacentBlock) && allowedMaterials.contains(adjacentBlock.getType())) {
toProcess.add(adjacentBlock);
}
}
}
return blocks;
} }
/** /**

View File

@@ -15,7 +15,7 @@ open class EcoConfig(
private val values = ConcurrentHashMap<String, Any?>() private val values = ConcurrentHashMap<String, Any?>()
@Transient @Transient
var injections = mutableListOf<InjectablePlaceholder>() var injections = ConcurrentHashMap<String, InjectablePlaceholder>()
fun init(values: Map<String, Any?>) { fun init(values: Map<String, Any?>) {
this.values.clear() this.values.clear()
@@ -104,12 +104,12 @@ open class EcoConfig(
} }
override fun getSubsectionOrNull(path: String): Config? { override fun getSubsectionOrNull(path: String): Config? {
return (get(path) as? Config)?.apply { this.addInjectablePlaceholder(injections) } return (get(path) as? Config)?.apply { this.addInjectablePlaceholder(injections.values) }
} }
override fun getSubsectionsOrNull(path: String): List<Config>? { override fun getSubsectionsOrNull(path: String): List<Config>? {
return getList<Config>(path) return getList<Config>(path)
?.map { it.apply { this.addInjectablePlaceholder(injections) } } ?.map { it.apply { this.addInjectablePlaceholder(injections.values) } }
?.toList() ?.toList()
} }
@@ -180,12 +180,13 @@ open class EcoConfig(
} }
override fun addInjectablePlaceholder(placeholders: Iterable<InjectablePlaceholder>) { override fun addInjectablePlaceholder(placeholders: Iterable<InjectablePlaceholder>) {
injections.removeIf { placeholders.any { placeholder -> it.identifier == placeholder.identifier } } for (placeholder in placeholders) {
injections.addAll(placeholders) injections[placeholder.identifier] = placeholder
}
} }
override fun getPlaceholderInjections(): List<InjectablePlaceholder> { override fun getPlaceholderInjections(): List<InjectablePlaceholder> {
return injections.toList() return injections.values.toList()
} }
override fun clearInjectedPlaceholders() { override fun clearInjectedPlaceholders() {

View File

@@ -2,14 +2,15 @@ package com.willfp.eco.internal.config
import com.willfp.eco.core.config.ConfigType import com.willfp.eco.core.config.ConfigType
import com.willfp.eco.core.placeholder.InjectablePlaceholder import com.willfp.eco.core.placeholder.InjectablePlaceholder
import java.util.concurrent.ConcurrentHashMap
class EcoConfigSection( class EcoConfigSection(
type: ConfigType, type: ConfigType,
values: Map<String, Any?> = emptyMap(), values: Map<String, Any?> = emptyMap(),
injections: Collection<InjectablePlaceholder> = emptyList() injections: MutableMap<String, InjectablePlaceholder> = mutableMapOf()
) : EcoConfig(type) { ) : EcoConfig(type) {
init { init {
this.init(values) this.init(values)
this.injections = injections.toMutableList() this.injections = ConcurrentHashMap(injections)
} }
} }

View File

@@ -185,4 +185,6 @@ dependencies:
required: false required: false
bootstrap: false bootstrap: false
- name: UltraEconomy
required: false
bootstrap: false

View File

@@ -51,3 +51,4 @@ softdepend:
- ModelEngine - ModelEngine
- PvPManager - PvPManager
- DeluxeMenus - DeluxeMenus
- UltraEconomy

View File

@@ -1,3 +1,3 @@
version = 6.55.1 version = 6.55.4
plugin-name = eco plugin-name = eco
kotlin.code.style = official kotlin.code.style = official