Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83f86983f6 | ||
|
|
3ba98a9a5e | ||
|
|
6ec80d30ad | ||
|
|
7ccee60a0c | ||
|
|
0805b48763 | ||
|
|
d737322aaa | ||
|
|
4ddc150e1c | ||
|
|
0da119d89d | ||
|
|
fc0a07d1c5 |
@@ -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("The integration will be disabled.");
|
||||
e.printStackTrace();
|
||||
this.remove(integration.getPluginName());
|
||||
this.remove(integration);
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,42 +8,15 @@ import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Utilities / API methods for blocks.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
@@ -56,7 +29,32 @@ public final class BlockUtils {
|
||||
public static Set<Block> getVein(@NotNull final Block start,
|
||||
@NotNull final List<Material> allowedMaterials,
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@ open class EcoConfig(
|
||||
private val values = ConcurrentHashMap<String, Any?>()
|
||||
|
||||
@Transient
|
||||
var injections = mutableListOf<InjectablePlaceholder>()
|
||||
var injections = ConcurrentHashMap<String, InjectablePlaceholder>()
|
||||
|
||||
fun init(values: Map<String, Any?>) {
|
||||
this.values.clear()
|
||||
@@ -104,12 +104,12 @@ open class EcoConfig(
|
||||
}
|
||||
|
||||
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>? {
|
||||
return getList<Config>(path)
|
||||
?.map { it.apply { this.addInjectablePlaceholder(injections) } }
|
||||
?.map { it.apply { this.addInjectablePlaceholder(injections.values) } }
|
||||
?.toList()
|
||||
}
|
||||
|
||||
@@ -180,12 +180,13 @@ open class EcoConfig(
|
||||
}
|
||||
|
||||
override fun addInjectablePlaceholder(placeholders: Iterable<InjectablePlaceholder>) {
|
||||
injections.removeIf { placeholders.any { placeholder -> it.identifier == placeholder.identifier } }
|
||||
injections.addAll(placeholders)
|
||||
for (placeholder in placeholders) {
|
||||
injections[placeholder.identifier] = placeholder
|
||||
}
|
||||
}
|
||||
|
||||
override fun getPlaceholderInjections(): List<InjectablePlaceholder> {
|
||||
return injections.toList()
|
||||
return injections.values.toList()
|
||||
}
|
||||
|
||||
override fun clearInjectedPlaceholders() {
|
||||
|
||||
@@ -2,14 +2,15 @@ package com.willfp.eco.internal.config
|
||||
|
||||
import com.willfp.eco.core.config.ConfigType
|
||||
import com.willfp.eco.core.placeholder.InjectablePlaceholder
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
class EcoConfigSection(
|
||||
type: ConfigType,
|
||||
values: Map<String, Any?> = emptyMap(),
|
||||
injections: Collection<InjectablePlaceholder> = emptyList()
|
||||
injections: MutableMap<String, InjectablePlaceholder> = mutableMapOf()
|
||||
) : EcoConfig(type) {
|
||||
init {
|
||||
this.init(values)
|
||||
this.injections = injections.toMutableList()
|
||||
this.injections = ConcurrentHashMap(injections)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,4 +185,6 @@ dependencies:
|
||||
required: false
|
||||
bootstrap: false
|
||||
|
||||
|
||||
- name: UltraEconomy
|
||||
required: false
|
||||
bootstrap: false
|
||||
|
||||
@@ -51,3 +51,4 @@ softdepend:
|
||||
- ModelEngine
|
||||
- PvPManager
|
||||
- DeluxeMenus
|
||||
- UltraEconomy
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version = 6.55.1
|
||||
version = 6.55.4
|
||||
plugin-name = eco
|
||||
kotlin.code.style = official
|
||||
Reference in New Issue
Block a user