Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8f710161d | ||
|
|
f840a55734 | ||
|
|
b6f2b9d4ea | ||
|
|
f320e77008 | ||
|
|
c8b255b358 | ||
|
|
5b5e161062 | ||
|
|
ffa511176f |
@@ -37,11 +37,19 @@ public class Prerequisite {
|
||||
"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.
|
||||
*/
|
||||
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+"
|
||||
);
|
||||
|
||||
@@ -49,7 +57,7 @@ public class Prerequisite {
|
||||
* Requires the server to be running 1.19.
|
||||
*/
|
||||
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+"
|
||||
);
|
||||
|
||||
|
||||
@@ -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)
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.willfp.eco.internal.config
|
||||
|
||||
import com.willfp.eco.core.config.interfaces.Config
|
||||
import org.yaml.snakeyaml.DumperOptions
|
||||
import org.yaml.snakeyaml.nodes.Node
|
||||
import org.yaml.snakeyaml.representer.Represent
|
||||
import org.yaml.snakeyaml.representer.Representer
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
class EcoRepresenter : Representer() {
|
||||
class EcoRepresenter : Representer(DumperOptions()) {
|
||||
init {
|
||||
multiRepresenters[Config::class.java] = RepresentConfig(multiRepresenters[Map::class.java]!!)
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ fun PacketEvent.handleSend() {
|
||||
listener.listener.onSend(this)
|
||||
} catch (e: Exception) {
|
||||
listener.plugin.logger.warning(
|
||||
"Exception in packet listener ${listener.listener.javaClass.simpleName}" +
|
||||
" for packet ${packet.javaClass.simpleName}!"
|
||||
"Exception in packet listener ${listener.listener.javaClass.name}" +
|
||||
" for packet ${packet.handle.javaClass.name}!"
|
||||
)
|
||||
e.printStackTrace()
|
||||
}
|
||||
@@ -40,8 +40,8 @@ fun PacketEvent.handleReceive() {
|
||||
listener.listener.onReceive(this)
|
||||
} catch (e: Exception) {
|
||||
listener.plugin.logger.warning(
|
||||
"Exception in packet listener ${listener.listener.javaClass.simpleName}" +
|
||||
" for packet ${packet.javaClass.simpleName}!"
|
||||
"Exception in packet listener ${listener.listener.javaClass.name}" +
|
||||
" for packet ${packet.handle.javaClass.name}!"
|
||||
)
|
||||
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.placeholder.InjectablePlaceholder
|
||||
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
|
||||
|
||||
/*
|
||||
|
||||
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(
|
||||
val args: String,
|
||||
val plugin: EcoPlugin?,
|
||||
@@ -29,6 +44,12 @@ class PlaceholderLookup(
|
||||
}
|
||||
}
|
||||
|
||||
for (placeholder in globalPlaceholders) {
|
||||
if (placeholder.matches(this)) {
|
||||
return placeholder
|
||||
}
|
||||
}
|
||||
|
||||
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.ArgParserEnchantment
|
||||
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.ArgParserTexture
|
||||
import com.willfp.eco.internal.items.ArgParserUnbreakable
|
||||
@@ -150,6 +151,7 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
|
||||
Items.registerArgParser(ArgParserFlag)
|
||||
Items.registerArgParser(ArgParserUnbreakable)
|
||||
Items.registerArgParser(ArgParserName)
|
||||
Items.registerArgParser(ArgParserHead)
|
||||
|
||||
Entities.registerArgParser(EntityArgParserName)
|
||||
Entities.registerArgParser(EntityArgParserNoAI)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version = 6.63.1
|
||||
version = 6.64.0
|
||||
plugin-name = eco
|
||||
kotlin.code.style = official
|
||||
Reference in New Issue
Block a user