Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
095494dd2e | ||
|
|
fd92645500 | ||
|
|
1a6ac29083 | ||
|
|
7edc00d459 | ||
|
|
a51bad058f | ||
|
|
89ebb8ba59 | ||
|
|
f0ae8f4f84 | ||
|
|
7d6cf78442 | ||
|
|
780d8f3b86 | ||
|
|
146a0130f9 | ||
|
|
df8c3411cb | ||
|
|
4fc3c22a7d | ||
|
|
cfc4808bb8 | ||
|
|
4ac6325a41 |
@@ -164,6 +164,11 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike, Regist
|
||||
*/
|
||||
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.
|
||||
* <p>
|
||||
@@ -632,6 +637,10 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike, Regist
|
||||
|
||||
this.handleLifecycle(this.onReload, this::handleReload);
|
||||
|
||||
if (cancelTasks) {
|
||||
this.handleLifecycle(this.createTasks, this::createTasks);
|
||||
}
|
||||
|
||||
for (Extension extension : this.extensionLoader.getLoadedExtensions()) {
|
||||
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.
|
||||
* <p>
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.willfp.eco.core.config.interfaces.Config;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -49,6 +50,11 @@ public final class PersistentDataKeyType<T> {
|
||||
*/
|
||||
public static final PersistentDataKeyType<Config> CONFIG = new PersistentDataKeyType<>("CONFIG");
|
||||
|
||||
/**
|
||||
* Big Decimal.
|
||||
*/
|
||||
public static final PersistentDataKeyType<BigDecimal> BIG_DECIMAL = new PersistentDataKeyType<>("BIG_DECIMAL");
|
||||
|
||||
/**
|
||||
* The name of the key type.
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,13 @@ import java.util.function.Supplier;
|
||||
* @param <T> The type of integration.
|
||||
*/
|
||||
public class IntegrationRegistry<T extends Integration> extends Registry<T> {
|
||||
/**
|
||||
* Create a new integration registry.
|
||||
*/
|
||||
public IntegrationRegistry() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull T register(@NotNull final T element) {
|
||||
return executeSafely(() -> super.register(element), element);
|
||||
|
||||
@@ -150,7 +150,7 @@ public class DefaultMap<K, V> implements Map<K, V> {
|
||||
*/
|
||||
@NotNull
|
||||
public static <K, K1, V> DefaultMap<K, Map<K1, V>> createNestedMap() {
|
||||
return new DefaultMap<>(new HashMap<>());
|
||||
return new DefaultMap<>(HashMap::new);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,6 +163,6 @@ public class DefaultMap<K, V> implements Map<K, V> {
|
||||
*/
|
||||
@NotNull
|
||||
public static <K, K1, V> DefaultMap<K, ListMap<K1, V>> createNestedListMap() {
|
||||
return new DefaultMap<>(new ListMap<>());
|
||||
return new DefaultMap<>(ListMap::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ package com.willfp.eco.core.map
|
||||
* @see ListMap
|
||||
*/
|
||||
@Suppress("RedundantOverride")
|
||||
class MutableListMap<K : Any, V : Any> : ListMap<K, V>() {
|
||||
class MutableListMap<K : Any, V> : ListMap<K, V>() {
|
||||
/**
|
||||
* Override with enforced MutableList type.
|
||||
*/
|
||||
@@ -18,7 +18,7 @@ class MutableListMap<K : Any, V : Any> : ListMap<K, V>() {
|
||||
/**
|
||||
* 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)
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,12 @@ class MutableListMap<K : Any, V : Any> : ListMap<K, V>() {
|
||||
fun <K : Any, V : Any> defaultMap(defaultValue: V) =
|
||||
DefaultMap<K, V>(defaultValue)
|
||||
|
||||
/**
|
||||
* @see DefaultMap
|
||||
*/
|
||||
fun <K : Any, V : Any> defaultMap(defaultValue: () -> V) =
|
||||
DefaultMap<K, V>(defaultValue())
|
||||
|
||||
/**
|
||||
* @see ListMap
|
||||
*/
|
||||
@@ -38,11 +44,13 @@ fun <K : Any, V : Any> listMap() =
|
||||
/**
|
||||
* @see DefaultMap.createNestedMap
|
||||
*/
|
||||
fun <K : Any, K1 : Any, V : Any> nestedMap() =
|
||||
fun <K : Any, K1 : Any, V> nestedMap() =
|
||||
DefaultMap.createNestedMap<K, K1, V>()
|
||||
|
||||
/**
|
||||
* @see DefaultMap.createNestedListMap
|
||||
*/
|
||||
fun <K : Any, K1 : Any, V : Any> nestedListMap() =
|
||||
DefaultMap<K, MutableListMap<K1, V>>(MutableListMap())
|
||||
fun <K : Any, K1 : Any, V> nestedListMap() =
|
||||
DefaultMap<K, MutableListMap<K1, V>>() {
|
||||
MutableListMap()
|
||||
}
|
||||
|
||||
@@ -15,5 +15,5 @@ fun <T> create2DList(rows: Int, columns: Int): MutableList<MutableList<T>> =
|
||||
ListUtils.create2DList(rows, columns)
|
||||
|
||||
/** @see ListUtils.toSingletonList */
|
||||
fun <T> T.toSingletonList(): List<T> =
|
||||
fun <T> T?.toSingletonList(): List<T> =
|
||||
ListUtils.toSingletonList(this)
|
||||
|
||||
@@ -8,10 +8,12 @@ import org.bukkit.command.TabCompleter
|
||||
|
||||
class DelegatedBukkitCommand(
|
||||
private val delegate: EcoPluginCommand
|
||||
) : Command(delegate.name), TabCompleter, PluginIdentifiableCommand {
|
||||
private var _aliases: List<String>? = null
|
||||
private var _description: String? = null
|
||||
|
||||
) : Command(
|
||||
delegate.name,
|
||||
delegate.description ?: "",
|
||||
"/${delegate.name}",
|
||||
delegate.aliases
|
||||
), TabCompleter, PluginIdentifiableCommand {
|
||||
override fun execute(sender: CommandSender, label: String, args: Array<out String>?): Boolean {
|
||||
return delegate.onCommand(sender, this, label, args)
|
||||
}
|
||||
@@ -36,16 +38,4 @@ class DelegatedBukkitCommand(
|
||||
|
||||
override fun getPlugin() = delegate.plugin
|
||||
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.PersistentDataKeyType
|
||||
import org.bukkit.NamespacedKey
|
||||
import java.math.BigDecimal
|
||||
|
||||
object KeyRegistry {
|
||||
private val registry = mutableMapOf<NamespacedKey, PersistentDataKey<*>>()
|
||||
@@ -44,6 +45,9 @@ object KeyRegistry {
|
||||
PersistentDataKeyType.CONFIG -> if (default !is 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!")
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.exposed.sql.insert
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
import java.math.BigDecimal
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
@@ -84,6 +85,9 @@ class MySQLDataHandler(
|
||||
PersistentDataKeyType.BOOLEAN -> data.getBoolOrNull(key.key.toString())
|
||||
PersistentDataKeyType.STRING_LIST -> data.getStringsOrNull(key.key.toString())
|
||||
PersistentDataKeyType.CONFIG -> data.getSubsectionOrNull(key.key.toString())
|
||||
PersistentDataKeyType.BIG_DECIMAL -> if (data.has(key.key.toString()))
|
||||
BigDecimal(data.getString(key.key.toString())) else null
|
||||
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.willfp.eco.core.data.keys.PersistentDataKeyType
|
||||
import com.willfp.eco.internal.spigot.EcoSpigotPlugin
|
||||
import com.willfp.eco.internal.spigot.data.ProfileHandler
|
||||
import org.bukkit.NamespacedKey
|
||||
import java.math.BigDecimal
|
||||
import java.util.UUID
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@@ -27,6 +28,9 @@ class YamlDataHandler(
|
||||
PersistentDataKeyType.BOOLEAN -> dataYml.getBoolOrNull("player.$uuid.${key.key}") as T?
|
||||
PersistentDataKeyType.STRING_LIST -> dataYml.getStringsOrNull("player.$uuid.${key.key}") as T?
|
||||
PersistentDataKeyType.CONFIG -> dataYml.getSubsectionOrNull("player.$uuid.${key.key}") as T?
|
||||
PersistentDataKeyType.BIG_DECIMAL -> (if (dataYml.has(key.key.toString()))
|
||||
BigDecimal(dataYml.getString(key.key.toString())) else null) as T?
|
||||
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version = 6.58.0
|
||||
version = 6.60.1
|
||||
plugin-name = eco
|
||||
kotlin.code.style = official
|
||||
Reference in New Issue
Block a user