Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c85b8c08c7 | ||
|
|
a65ac0aa4f | ||
|
|
9d03ba2bd2 | ||
|
|
8eb62d65b4 | ||
|
|
178f21b1f3 | ||
|
|
a3fe4f97ff | ||
|
|
ff356fcde5 | ||
|
|
59b57b17ba | ||
|
|
c8f710161d | ||
|
|
f840a55734 | ||
|
|
b6f2b9d4ea | ||
|
|
f320e77008 | ||
|
|
c8b255b358 | ||
|
|
5b5e161062 | ||
|
|
ffa511176f |
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
* @WillFP
|
||||||
21
.github/workflows/master-pr.yml
vendored
Normal file
21
.github/workflows/master-pr.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
name: PR Alert for Master Branch
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
alert:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Comment PR
|
||||||
|
uses: actions/github-script@v5
|
||||||
|
with:
|
||||||
|
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
script: |
|
||||||
|
github.issues.createComment({
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
body: '⚠️ PRs should not be opened against the `master` branch directly. Please use the `develop` branch as the base for your PRs. ⚠️'
|
||||||
|
})
|
||||||
@@ -37,11 +37,19 @@ public class Prerequisite {
|
|||||||
"Requires server to have ProtocolLib"
|
"Requires server to have ProtocolLib"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requires the server to be running 1.20.
|
||||||
|
*/
|
||||||
|
public static final Prerequisite HAS_1_20 = new Prerequisite(
|
||||||
|
() -> ProxyConstants.NMS_VERSION.contains("20"),
|
||||||
|
"Requires server to be running 1.20+"
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requires the server to be running 1.19.4.
|
* Requires the server to be running 1.19.4.
|
||||||
*/
|
*/
|
||||||
public static final Prerequisite HAS_1_19_4 = new Prerequisite(
|
public static final Prerequisite HAS_1_19_4 = new Prerequisite(
|
||||||
() -> ProxyConstants.NMS_VERSION.contains("19_R3"),
|
() -> ProxyConstants.NMS_VERSION.contains("19_R3") || HAS_1_20.isMet(),
|
||||||
"Requires server to be running 1.19.4+"
|
"Requires server to be running 1.19.4+"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -49,7 +57,7 @@ public class Prerequisite {
|
|||||||
* Requires the server to be running 1.19.
|
* Requires the server to be running 1.19.
|
||||||
*/
|
*/
|
||||||
public static final Prerequisite HAS_1_19 = new Prerequisite(
|
public static final Prerequisite HAS_1_19 = new Prerequisite(
|
||||||
() -> ProxyConstants.NMS_VERSION.contains("19"),
|
() -> ProxyConstants.NMS_VERSION.contains("19") || HAS_1_20.isMet(),
|
||||||
"Requires server to be running 1.19+"
|
"Requires server to be running 1.19+"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -648,6 +649,32 @@ public interface Config extends Cloneable, PlaceholderInjectable {
|
|||||||
@Nullable
|
@Nullable
|
||||||
List<? extends Config> getSubsectionsOrNull(@NotNull String path);
|
List<? extends Config> getSubsectionsOrNull(@NotNull String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a big decimal from config.
|
||||||
|
*
|
||||||
|
* @param path The key to fetch the value from.
|
||||||
|
* @return The found value, or 0 if not found.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
default BigDecimal getBigDecimal(@NotNull final String path) {
|
||||||
|
return Objects.requireNonNullElse(getBigDecimalOrNull(path), BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a big decimal from config.
|
||||||
|
*
|
||||||
|
* @param path The key to fetch the value from.
|
||||||
|
* @return The found value, or null if not found.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
default BigDecimal getBigDecimalOrNull(@NotNull final String path) {
|
||||||
|
if (this.has(path)) {
|
||||||
|
return new BigDecimal(this.getString(path));
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get config type.
|
* Get config type.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -169,7 +169,15 @@ public final class PlaceholderManager {
|
|||||||
public static String translatePlaceholders(@NotNull final String text,
|
public static String translatePlaceholders(@NotNull final String text,
|
||||||
@Nullable final Player player,
|
@Nullable final Player player,
|
||||||
@NotNull final PlaceholderInjectable context) {
|
@NotNull final PlaceholderInjectable context) {
|
||||||
return translatePlaceholders(text, player, context, new ArrayList<>());
|
return translatePlaceholders(
|
||||||
|
text,
|
||||||
|
new PlaceholderContext(
|
||||||
|
player,
|
||||||
|
null,
|
||||||
|
context,
|
||||||
|
new ArrayList<>()
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
@file:JvmName("PlaceholderExtensions")
|
||||||
|
|
||||||
|
package com.willfp.eco.core.placeholder
|
||||||
|
|
||||||
|
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager
|
||||||
|
import com.willfp.eco.core.placeholder.context.PlaceholderContext
|
||||||
|
|
||||||
|
/** @see PlaceholderManager.translatePlaceholders */
|
||||||
|
fun String.translatePlaceholders(context: PlaceholderContext) =
|
||||||
|
PlaceholderManager.translatePlaceholders(this, context)
|
||||||
|
|
||||||
|
/** @see PlaceholderManager.findPlaceholdersIn */
|
||||||
|
fun String.findPlaceholders(): List<String> =
|
||||||
|
PlaceholderManager.findPlaceholdersIn(this)
|
||||||
@@ -106,7 +106,7 @@ abstract class HandledCommand(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
notifyFalse(!isPlayersOnly || sender is Player, LangYml.KEY_NOT_PLAYER)
|
notifyFalse(!isPlayersOnly || sender is Player, "not-player")
|
||||||
|
|
||||||
onExecute(sender, args)
|
onExecute(sender, args)
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.willfp.eco.internal.config
|
package com.willfp.eco.internal.config
|
||||||
|
|
||||||
import com.willfp.eco.core.config.interfaces.Config
|
import com.willfp.eco.core.config.interfaces.Config
|
||||||
|
import org.yaml.snakeyaml.DumperOptions
|
||||||
import org.yaml.snakeyaml.nodes.Node
|
import org.yaml.snakeyaml.nodes.Node
|
||||||
import org.yaml.snakeyaml.representer.Represent
|
import org.yaml.snakeyaml.representer.Represent
|
||||||
import org.yaml.snakeyaml.representer.Representer
|
import org.yaml.snakeyaml.representer.Representer
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
class EcoRepresenter : Representer(DumperOptions()) {
|
||||||
class EcoRepresenter : Representer() {
|
|
||||||
init {
|
init {
|
||||||
multiRepresenters[Config::class.java] = RepresentConfig(multiRepresenters[Map::class.java]!!)
|
multiRepresenters[Config::class.java] = RepresentConfig(multiRepresenters[Map::class.java]!!)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ fun PacketEvent.handleSend() {
|
|||||||
listener.listener.onSend(this)
|
listener.listener.onSend(this)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
listener.plugin.logger.warning(
|
listener.plugin.logger.warning(
|
||||||
"Exception in packet listener ${listener.listener.javaClass.simpleName}" +
|
"Exception in packet listener ${listener.listener.javaClass.name}" +
|
||||||
" for packet ${packet.javaClass.simpleName}!"
|
" for packet ${packet.handle.javaClass.name}!"
|
||||||
)
|
)
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
@@ -40,8 +40,8 @@ fun PacketEvent.handleReceive() {
|
|||||||
listener.listener.onReceive(this)
|
listener.listener.onReceive(this)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
listener.plugin.logger.warning(
|
listener.plugin.logger.warning(
|
||||||
"Exception in packet listener ${listener.listener.javaClass.simpleName}" +
|
"Exception in packet listener ${listener.listener.javaClass.name}" +
|
||||||
" for packet ${packet.javaClass.simpleName}!"
|
" for packet ${packet.handle.javaClass.name}!"
|
||||||
)
|
)
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.willfp.eco.internal.items
|
||||||
|
|
||||||
|
import com.willfp.eco.core.items.args.LookupArgParser
|
||||||
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta
|
||||||
|
import java.util.function.Predicate
|
||||||
|
|
||||||
|
object ArgParserHead : LookupArgParser {
|
||||||
|
override fun parseArguments(args: Array<out String>, meta: ItemMeta): Predicate<ItemStack>? {
|
||||||
|
if (meta !is SkullMeta) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
var playerName: String? = null
|
||||||
|
|
||||||
|
for (arg in args) {
|
||||||
|
val argSplit = arg.split(":")
|
||||||
|
if (!argSplit[0].equals("head", ignoreCase = true)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (argSplit.size < 2) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
playerName = argSplit[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
playerName ?: return null
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
val player = Bukkit.getOfflinePlayer(playerName)
|
||||||
|
|
||||||
|
meta.owningPlayer = player
|
||||||
|
|
||||||
|
return Predicate {
|
||||||
|
val testMeta = it.itemMeta as? SkullMeta ?: return@Predicate false
|
||||||
|
testMeta.owningPlayer?.uniqueId == player.uniqueId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serializeBack(meta: ItemMeta): String? {
|
||||||
|
if (meta !is SkullMeta) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (meta.owningPlayer == null) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return "head:${meta.owningPlayer?.name}"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,8 +4,23 @@ import com.willfp.eco.core.EcoPlugin
|
|||||||
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager
|
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager
|
||||||
import com.willfp.eco.core.placeholder.InjectablePlaceholder
|
import com.willfp.eco.core.placeholder.InjectablePlaceholder
|
||||||
import com.willfp.eco.core.placeholder.Placeholder
|
import com.willfp.eco.core.placeholder.Placeholder
|
||||||
|
import com.willfp.eco.core.placeholder.context.PlaceholderContext
|
||||||
|
import com.willfp.eco.core.placeholder.templates.SimpleInjectablePlaceholder
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
A set of global placeholders that are always available.
|
||||||
|
|
||||||
|
*/
|
||||||
|
private val globalPlaceholders = setOf<Placeholder>(
|
||||||
|
object : SimpleInjectablePlaceholder("player") {
|
||||||
|
override fun getValue(args: String, context: PlaceholderContext): String? {
|
||||||
|
return context.player?.name
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
class PlaceholderLookup(
|
class PlaceholderLookup(
|
||||||
val args: String,
|
val args: String,
|
||||||
val plugin: EcoPlugin?,
|
val plugin: EcoPlugin?,
|
||||||
@@ -29,6 +44,12 @@ class PlaceholderLookup(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (placeholder in globalPlaceholders) {
|
||||||
|
if (placeholder.matches(this)) {
|
||||||
|
return placeholder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import com.willfp.eco.internal.items.ArgParserColor
|
|||||||
import com.willfp.eco.internal.items.ArgParserCustomModelData
|
import com.willfp.eco.internal.items.ArgParserCustomModelData
|
||||||
import com.willfp.eco.internal.items.ArgParserEnchantment
|
import com.willfp.eco.internal.items.ArgParserEnchantment
|
||||||
import com.willfp.eco.internal.items.ArgParserFlag
|
import com.willfp.eco.internal.items.ArgParserFlag
|
||||||
|
import com.willfp.eco.internal.items.ArgParserHead
|
||||||
import com.willfp.eco.internal.items.ArgParserName
|
import com.willfp.eco.internal.items.ArgParserName
|
||||||
import com.willfp.eco.internal.items.ArgParserTexture
|
import com.willfp.eco.internal.items.ArgParserTexture
|
||||||
import com.willfp.eco.internal.items.ArgParserUnbreakable
|
import com.willfp.eco.internal.items.ArgParserUnbreakable
|
||||||
@@ -150,6 +151,7 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
|
|||||||
Items.registerArgParser(ArgParserFlag)
|
Items.registerArgParser(ArgParserFlag)
|
||||||
Items.registerArgParser(ArgParserUnbreakable)
|
Items.registerArgParser(ArgParserUnbreakable)
|
||||||
Items.registerArgParser(ArgParserName)
|
Items.registerArgParser(ArgParserName)
|
||||||
|
Items.registerArgParser(ArgParserHead)
|
||||||
|
|
||||||
Entities.registerArgParser(EntityArgParserName)
|
Entities.registerArgParser(EntityArgParserName)
|
||||||
Entities.registerArgParser(EntityArgParserNoAI)
|
Entities.registerArgParser(EntityArgParserNoAI)
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import org.jetbrains.exposed.sql.insert
|
|||||||
import org.jetbrains.exposed.sql.select
|
import org.jetbrains.exposed.sql.select
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
import org.jetbrains.exposed.sql.update
|
import org.jetbrains.exposed.sql.update
|
||||||
import java.math.BigDecimal
|
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
@@ -85,8 +84,7 @@ class MySQLDataHandler(
|
|||||||
PersistentDataKeyType.BOOLEAN -> data.getBoolOrNull(key.key.toString())
|
PersistentDataKeyType.BOOLEAN -> data.getBoolOrNull(key.key.toString())
|
||||||
PersistentDataKeyType.STRING_LIST -> data.getStringsOrNull(key.key.toString())
|
PersistentDataKeyType.STRING_LIST -> data.getStringsOrNull(key.key.toString())
|
||||||
PersistentDataKeyType.CONFIG -> data.getSubsectionOrNull(key.key.toString())
|
PersistentDataKeyType.CONFIG -> data.getSubsectionOrNull(key.key.toString())
|
||||||
PersistentDataKeyType.BIG_DECIMAL -> if (data.has(key.key.toString()))
|
PersistentDataKeyType.BIG_DECIMAL -> data.getBigDecimalOrNull(key.key.toString())
|
||||||
BigDecimal(data.getString(key.key.toString())) else null
|
|
||||||
|
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.willfp.eco.core.data.keys.PersistentDataKeyType
|
|||||||
import com.willfp.eco.internal.spigot.EcoSpigotPlugin
|
import com.willfp.eco.internal.spigot.EcoSpigotPlugin
|
||||||
import com.willfp.eco.internal.spigot.data.ProfileHandler
|
import com.willfp.eco.internal.spigot.data.ProfileHandler
|
||||||
import org.bukkit.NamespacedKey
|
import org.bukkit.NamespacedKey
|
||||||
import java.math.BigDecimal
|
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
@@ -28,8 +27,7 @@ class YamlDataHandler(
|
|||||||
PersistentDataKeyType.BOOLEAN -> dataYml.getBoolOrNull("player.$uuid.${key.key}") as T?
|
PersistentDataKeyType.BOOLEAN -> dataYml.getBoolOrNull("player.$uuid.${key.key}") as T?
|
||||||
PersistentDataKeyType.STRING_LIST -> dataYml.getStringsOrNull("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.CONFIG -> dataYml.getSubsectionOrNull("player.$uuid.${key.key}") as T?
|
||||||
PersistentDataKeyType.BIG_DECIMAL -> (if (dataYml.has(key.key.toString()))
|
PersistentDataKeyType.BIG_DECIMAL -> dataYml.getBigDecimalOrNull("player.$uuid.${key.key}") as T?
|
||||||
BigDecimal(dataYml.getString(key.key.toString())) else null) as T?
|
|
||||||
|
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version = 6.63.1
|
version = 6.65.0
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
Reference in New Issue
Block a user