Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
095494dd2e | ||
|
|
fd92645500 | ||
|
|
1a6ac29083 | ||
|
|
7edc00d459 | ||
|
|
a51bad058f | ||
|
|
89ebb8ba59 | ||
|
|
f0ae8f4f84 |
@@ -164,6 +164,11 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike, Regist
|
|||||||
*/
|
*/
|
||||||
private final ListMap<LifecyclePosition, Runnable> afterLoad = new ListMap<>();
|
private final ListMap<LifecyclePosition, Runnable> afterLoad = new ListMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tasks to run on task creation.
|
||||||
|
*/
|
||||||
|
private final ListMap<LifecyclePosition, Runnable> createTasks = new ListMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new plugin.
|
* Create a new plugin.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -632,6 +637,10 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike, Regist
|
|||||||
|
|
||||||
this.handleLifecycle(this.onReload, this::handleReload);
|
this.handleLifecycle(this.onReload, this::handleReload);
|
||||||
|
|
||||||
|
if (cancelTasks) {
|
||||||
|
this.handleLifecycle(this.createTasks, this::createTasks);
|
||||||
|
}
|
||||||
|
|
||||||
for (Extension extension : this.extensionLoader.getLoadedExtensions()) {
|
for (Extension extension : this.extensionLoader.getLoadedExtensions()) {
|
||||||
extension.handleReload();
|
extension.handleReload();
|
||||||
}
|
}
|
||||||
@@ -745,6 +754,15 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike, Regist
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The plugin-specific code to create tasks.
|
||||||
|
* <p>
|
||||||
|
* Override when needed.
|
||||||
|
*/
|
||||||
|
protected void createTasks() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plugin-specific code to be executed after the server is up.
|
* The plugin-specific code to be executed after the server is up.
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -17,6 +17,13 @@ import java.util.function.Supplier;
|
|||||||
* @param <T> The type of integration.
|
* @param <T> The type of integration.
|
||||||
*/
|
*/
|
||||||
public class IntegrationRegistry<T extends Integration> extends Registry<T> {
|
public class IntegrationRegistry<T extends Integration> extends Registry<T> {
|
||||||
|
/**
|
||||||
|
* Create a new integration registry.
|
||||||
|
*/
|
||||||
|
public IntegrationRegistry() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull T register(@NotNull final T element) {
|
public @NotNull T register(@NotNull final T element) {
|
||||||
return executeSafely(() -> super.register(element), element);
|
return executeSafely(() -> super.register(element), element);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ package com.willfp.eco.core.map
|
|||||||
* @see ListMap
|
* @see ListMap
|
||||||
*/
|
*/
|
||||||
@Suppress("RedundantOverride")
|
@Suppress("RedundantOverride")
|
||||||
class MutableListMap<K : Any, V : Any> : ListMap<K, V>() {
|
class MutableListMap<K : Any, V> : ListMap<K, V>() {
|
||||||
/**
|
/**
|
||||||
* Override with enforced MutableList type.
|
* Override with enforced MutableList type.
|
||||||
*/
|
*/
|
||||||
@@ -18,7 +18,7 @@ class MutableListMap<K : Any, V : Any> : ListMap<K, V>() {
|
|||||||
/**
|
/**
|
||||||
* Override with enforced MutableList type.
|
* Override with enforced MutableList type.
|
||||||
*/
|
*/
|
||||||
override fun getOrDefault(key: K, defaultValue: MutableList<V>?): MutableList<V> {
|
override fun getOrDefault(key: K, defaultValue: MutableList<V>): MutableList<V> {
|
||||||
return super.getOrDefault(key, defaultValue)
|
return super.getOrDefault(key, defaultValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,13 +44,13 @@ fun <K : Any, V : Any> listMap() =
|
|||||||
/**
|
/**
|
||||||
* @see DefaultMap.createNestedMap
|
* @see DefaultMap.createNestedMap
|
||||||
*/
|
*/
|
||||||
fun <K : Any, K1 : Any, V : Any> nestedMap() =
|
fun <K : Any, K1 : Any, V> nestedMap() =
|
||||||
DefaultMap.createNestedMap<K, K1, V>()
|
DefaultMap.createNestedMap<K, K1, V>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see DefaultMap.createNestedListMap
|
* @see DefaultMap.createNestedListMap
|
||||||
*/
|
*/
|
||||||
fun <K : Any, K1 : Any, V : Any> nestedListMap() =
|
fun <K : Any, K1 : Any, V> nestedListMap() =
|
||||||
DefaultMap<K, MutableListMap<K1, V>>() {
|
DefaultMap<K, MutableListMap<K1, V>>() {
|
||||||
MutableListMap()
|
MutableListMap()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ import org.bukkit.command.TabCompleter
|
|||||||
|
|
||||||
class DelegatedBukkitCommand(
|
class DelegatedBukkitCommand(
|
||||||
private val delegate: EcoPluginCommand
|
private val delegate: EcoPluginCommand
|
||||||
) : Command(delegate.name), TabCompleter, PluginIdentifiableCommand {
|
) : Command(
|
||||||
private var _aliases: List<String>? = null
|
delegate.name,
|
||||||
private var _description: String? = null
|
delegate.description ?: "",
|
||||||
|
"/${delegate.name}",
|
||||||
|
delegate.aliases
|
||||||
|
), TabCompleter, PluginIdentifiableCommand {
|
||||||
override fun execute(sender: CommandSender, label: String, args: Array<out String>?): Boolean {
|
override fun execute(sender: CommandSender, label: String, args: Array<out String>?): Boolean {
|
||||||
return delegate.onCommand(sender, this, label, args)
|
return delegate.onCommand(sender, this, label, args)
|
||||||
}
|
}
|
||||||
@@ -36,16 +38,4 @@ class DelegatedBukkitCommand(
|
|||||||
|
|
||||||
override fun getPlugin() = delegate.plugin
|
override fun getPlugin() = delegate.plugin
|
||||||
override fun getPermission() = delegate.permission
|
override fun getPermission() = delegate.permission
|
||||||
override fun getDescription() = _description ?: delegate.description ?: ""
|
|
||||||
override fun getAliases(): List<String> = _aliases ?: delegate.aliases
|
|
||||||
|
|
||||||
override fun setDescription(description: String): Command {
|
|
||||||
this._description = description
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setAliases(aliases: List<String>): Command {
|
|
||||||
this._aliases = aliases
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.willfp.eco.core.config.interfaces.Config
|
|||||||
import com.willfp.eco.core.data.keys.PersistentDataKey
|
import com.willfp.eco.core.data.keys.PersistentDataKey
|
||||||
import com.willfp.eco.core.data.keys.PersistentDataKeyType
|
import com.willfp.eco.core.data.keys.PersistentDataKeyType
|
||||||
import org.bukkit.NamespacedKey
|
import org.bukkit.NamespacedKey
|
||||||
|
import java.math.BigDecimal
|
||||||
|
|
||||||
object KeyRegistry {
|
object KeyRegistry {
|
||||||
private val registry = mutableMapOf<NamespacedKey, PersistentDataKey<*>>()
|
private val registry = mutableMapOf<NamespacedKey, PersistentDataKey<*>>()
|
||||||
@@ -44,6 +45,9 @@ object KeyRegistry {
|
|||||||
PersistentDataKeyType.CONFIG -> if (default !is Config) {
|
PersistentDataKeyType.CONFIG -> if (default !is Config) {
|
||||||
throw IllegalArgumentException("Invalid Data Type! Should be Config")
|
throw IllegalArgumentException("Invalid Data Type! Should be Config")
|
||||||
}
|
}
|
||||||
|
PersistentDataKeyType.BIG_DECIMAL -> if (default !is BigDecimal) {
|
||||||
|
throw IllegalArgumentException("Invalid Data Type! Should be BigDecimal")
|
||||||
|
}
|
||||||
|
|
||||||
else -> throw NullPointerException("Null value found!")
|
else -> throw NullPointerException("Null value found!")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version = 6.59.0
|
version = 6.60.1
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
Reference in New Issue
Block a user