Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff61527939 | ||
|
|
7ff578f89b | ||
|
|
27da03e8db | ||
|
|
f1bef38046 | ||
|
|
ee237f9c58 | ||
|
|
0a80518755 | ||
|
|
134859fea0 | ||
|
|
5c267d500a | ||
|
|
4c9735583c | ||
|
|
739d9cfffb | ||
|
|
4301d83e91 | ||
|
|
84d5c5e665 | ||
|
|
50f217eebe | ||
|
|
041fce69cc | ||
|
|
238bd08502 | ||
|
|
940e6e8b5b | ||
|
|
eb07622496 | ||
|
|
841ed52bdd | ||
|
|
342f6dbc7b | ||
|
|
245b577adc | ||
|
|
1258305755 | ||
|
|
cd8ed5a823 | ||
|
|
795ead57bf | ||
|
|
910cdaf992 | ||
|
|
85c02d3402 | ||
|
|
b4ad2fd4d7 | ||
|
|
3c5190da3a | ||
|
|
0f0f003f23 | ||
|
|
7e5e5162c3 | ||
|
|
09417d0834 | ||
|
|
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. ⚠️'
|
||||
})
|
||||
@@ -10,7 +10,7 @@ buildscript {
|
||||
|
||||
plugins {
|
||||
id("java-library")
|
||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||
id("maven-publish")
|
||||
id("java")
|
||||
kotlin("jvm") version "1.7.10"
|
||||
|
||||
@@ -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+"
|
||||
);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -596,7 +597,10 @@ public interface Config extends Cloneable, PlaceholderInjectable {
|
||||
*/
|
||||
default double getDoubleFromExpression(@NotNull String path,
|
||||
@NotNull PlaceholderContext context) {
|
||||
return NumberUtils.evaluateExpression(this.getString(path), context.withInjectableContext(this));
|
||||
return Objects.requireNonNullElseGet(
|
||||
this.getDoubleOrNull(path),
|
||||
() -> NumberUtils.evaluateExpression(this.getString(path), context.withInjectableContext(this))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -648,6 +652,32 @@ public interface Config extends Cloneable, PlaceholderInjectable {
|
||||
@Nullable
|
||||
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.
|
||||
*
|
||||
|
||||
@@ -169,7 +169,15 @@ public final class PlaceholderManager {
|
||||
public static String translatePlaceholders(@NotNull final String text,
|
||||
@Nullable final Player player,
|
||||
@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 {
|
||||
notifyFalse(!isPlayersOnly || sender is Player, LangYml.KEY_NOT_PLAYER)
|
||||
notifyFalse(!isPlayersOnly || sender is Player, "not-player")
|
||||
|
||||
onExecute(sender, args)
|
||||
|
||||
|
||||
@@ -16,11 +16,16 @@ open class EcoConfig(
|
||||
private val values = ConcurrentHashMap<String, Any?>()
|
||||
|
||||
@Transient
|
||||
var injections = ConcurrentHashMap<String, InjectablePlaceholder>()
|
||||
private val injections = mutableMapOf<String, InjectablePlaceholder>()
|
||||
|
||||
fun init(values: Map<String, Any?>) {
|
||||
@Transient
|
||||
private var injectionHash = 0
|
||||
|
||||
fun init(values: Map<String, Any?>, injections: Map<String, InjectablePlaceholder>) {
|
||||
this.values.clear()
|
||||
this.values.putAll(values.normalizeToConfig(this.type))
|
||||
|
||||
this.addInjectablePlaceholder(injections.values)
|
||||
}
|
||||
|
||||
override fun toPlaintext(): String {
|
||||
@@ -179,6 +184,7 @@ open class EcoConfig(
|
||||
override fun addInjectablePlaceholder(placeholders: Iterable<InjectablePlaceholder>) {
|
||||
for (placeholder in placeholders) {
|
||||
injections[placeholder.pattern.pattern()] = placeholder
|
||||
injectionHash = injectionHash xor placeholder.hashCode()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,6 +194,7 @@ open class EcoConfig(
|
||||
|
||||
override fun clearInjectedPlaceholders() {
|
||||
injections.clear()
|
||||
injectionHash = 0 // Reset the hash
|
||||
}
|
||||
|
||||
override fun toMap(): MutableMap<String, Any?> {
|
||||
@@ -239,18 +246,6 @@ open class EcoConfig(
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
/*
|
||||
The keys are completely redundant, as they are only used to prevent
|
||||
duplicate keys in the map. Therefore, we can ignore them and just
|
||||
hash the actual placeholder values.
|
||||
*/
|
||||
|
||||
var injectionHash = 0
|
||||
|
||||
injections.forEachValue(5) {
|
||||
injectionHash = injectionHash xor (it.hashCode() shl 5)
|
||||
}
|
||||
|
||||
// hashCode() has to compute extremely quickly, so we're using bitwise, because why not?
|
||||
// Fucking filthy to use identityHashCode here, but it should be extremely fast
|
||||
val identityHash = System.identityHashCode(this)
|
||||
|
||||
@@ -10,7 +10,6 @@ class EcoConfigSection(
|
||||
injections: Map<String, InjectablePlaceholder> = emptyMap()
|
||||
) : EcoConfig(type) {
|
||||
init {
|
||||
this.init(values)
|
||||
this.injections = ConcurrentHashMap(injections)
|
||||
this.init(values, injections)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ open class EcoLoadableConfig(
|
||||
protected fun init(reader: Reader) {
|
||||
val string = reader.readToString()
|
||||
makeHeader(string)
|
||||
super.init(type.toMap(string))
|
||||
super.init(type.toMap(string), emptyMap())
|
||||
}
|
||||
|
||||
fun init(file: File) {
|
||||
|
||||
@@ -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]!!)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ open class EcoUpdatableConfig(
|
||||
val reader = BufferedReader(InputStreamReader(newIn, StandardCharsets.UTF_8))
|
||||
|
||||
val config = EcoConfigSection(type, emptyMap())
|
||||
config.init(type.toMap(reader.readToString()))
|
||||
config.init(type.toMap(reader.readToString()), emptyMap())
|
||||
return config
|
||||
}
|
||||
|
||||
|
||||
@@ -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,57 @@
|
||||
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
|
||||
}
|
||||
|
||||
if (meta.owningPlayer!!.name.equals("null", true) || meta.owningPlayer!!.name == 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
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ dependencies {
|
||||
implementation("org.jetbrains.exposed:exposed-jdbc:0.37.3")
|
||||
implementation("com.zaxxer:HikariCP:5.0.0")
|
||||
implementation("net.kyori:adventure-platform-bukkit:4.1.0")
|
||||
implementation("org.javassist:javassist:3.28.0-GA")
|
||||
implementation("org.javassist:javassist:3.29.2-GA")
|
||||
implementation("org.mongodb:mongodb-driver-sync:4.6.0")
|
||||
implementation("org.litote.kmongo:kmongo-coroutine:4.6.0")
|
||||
implementation("com.moandjiezana.toml:toml4j:0.7.2") {
|
||||
@@ -40,7 +40,7 @@ dependencies {
|
||||
compileOnly("com.github.oraxen:oraxen:1.155.0")
|
||||
compileOnly("com.github.brcdev-minecraft:shopgui-api:3.0.0")
|
||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:2.4.7")
|
||||
compileOnly("com.arcaniax:HeadDatabase-API:1.3.0")
|
||||
compileOnly("com.arcaniax:HeadDatabase-API:1.3.1")
|
||||
compileOnly("com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.4.0")
|
||||
compileOnly("com.github.EssentialsX:Essentials:2.18.2")
|
||||
compileOnly("com.bgsoftware:SuperiorSkyblockAPI:1.8.3")
|
||||
@@ -54,7 +54,7 @@ dependencies {
|
||||
compileOnly("me.TechsCode:UltraEconomyAPI:1.0.0")
|
||||
compileOnly("org.black_ixx:playerpoints:3.2.5")
|
||||
compileOnly("com.github.Ssomar-Developement:SCore:3.4.7")
|
||||
compileOnly("io.lumine:Mythic:5.2.1")
|
||||
compileOnly("io.lumine:Mythic:5.3.5")
|
||||
compileOnly("io.lumine:LumineUtils:1.19-SNAPSHOT")
|
||||
compileOnly("com.SirBlobman.combatlogx:CombatLogX-API:10.0.0.0-SNAPSHOT")
|
||||
compileOnly("com.github.sirblobman.combatlogx:api:11.0.0.0-SNAPSHOT")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -21,7 +21,6 @@ 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
|
||||
@@ -85,8 +84,7 @@ 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
|
||||
PersistentDataKeyType.BIG_DECIMAL -> data.getBigDecimalOrNull(key.key.toString())
|
||||
|
||||
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.data.ProfileHandler
|
||||
import org.bukkit.NamespacedKey
|
||||
import java.math.BigDecimal
|
||||
import java.util.UUID
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@@ -28,8 +27,7 @@ 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?
|
||||
PersistentDataKeyType.BIG_DECIMAL -> dataYml.getBigDecimalOrNull("player.$uuid.${key.key}") as T?
|
||||
|
||||
else -> null
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ import org.bukkit.block.Block
|
||||
import org.bukkit.entity.LivingEntity
|
||||
import org.bukkit.entity.Player
|
||||
import org.kingdoms.constants.group.Kingdom
|
||||
import org.kingdoms.constants.group.model.relationships.StandardRelationAttribute
|
||||
import org.kingdoms.constants.land.Land
|
||||
import org.kingdoms.constants.land.location.SimpleChunkLocation
|
||||
import org.kingdoms.constants.player.KingdomPlayer
|
||||
import org.kingdoms.constants.player.StandardKingdomPermission
|
||||
import org.kingdoms.managers.PvPManager
|
||||
import org.kingdoms.managers.land.BuildingProcessor
|
||||
|
||||
class AntigriefKingdoms : AntigriefIntegration {
|
||||
override fun canBreakBlock(
|
||||
@@ -21,34 +21,35 @@ class AntigriefKingdoms : AntigriefIntegration {
|
||||
if (kp.isAdmin) {
|
||||
return true
|
||||
}
|
||||
val kingdom: Kingdom = kp.kingdom ?: return false
|
||||
val land = Land.getLand(block) ?: return true
|
||||
val permission = if (land.isNexusLand) {
|
||||
StandardKingdomPermission.NEXUS_BUILD
|
||||
} else StandardKingdomPermission.BUILD
|
||||
|
||||
return if (!kp.hasPermission(permission)) {
|
||||
return BuildingProcessor(
|
||||
player,
|
||||
kp,
|
||||
SimpleChunkLocation.of(block),
|
||||
false
|
||||
} else kingdom.hasAttribute(land.kingdom, StandardRelationAttribute.BUILD)
|
||||
).process().isSuccessful
|
||||
}
|
||||
|
||||
override fun canCreateExplosion(
|
||||
player: Player,
|
||||
location: Location
|
||||
): Boolean {
|
||||
val land = Land.getLand(location) ?: return true
|
||||
if (!land.isClaimed) {
|
||||
return true
|
||||
}
|
||||
val kingdom: Kingdom = land.kingdom
|
||||
return kingdom.isMember(player)
|
||||
return canBreakBlock(player, location.block)
|
||||
}
|
||||
|
||||
override fun canPlaceBlock(
|
||||
player: Player,
|
||||
block: Block
|
||||
): Boolean {
|
||||
return canBreakBlock(player, block)
|
||||
val kp: KingdomPlayer = KingdomPlayer.getKingdomPlayer(player)
|
||||
if (kp.isAdmin) {
|
||||
return true
|
||||
}
|
||||
return BuildingProcessor(
|
||||
player,
|
||||
kp,
|
||||
SimpleChunkLocation.of(block),
|
||||
true
|
||||
).process().isSuccessful
|
||||
}
|
||||
|
||||
override fun canInjure(
|
||||
|
||||
@@ -17,7 +17,7 @@ class CustomEntitiesMythicMobs : CustomEntitiesIntegration {
|
||||
CustomEntity(
|
||||
key,
|
||||
{
|
||||
val entityId = api.getMythicMobInstance(it)?.type?.entityType?.name ?: return@CustomEntity false
|
||||
val entityId = api.getMythicMobInstance(it)?.type?.internalName ?: return@CustomEntity false
|
||||
entityId.equals(id, ignoreCase = true)
|
||||
},
|
||||
{
|
||||
|
||||
@@ -15,6 +15,8 @@ class DelegatedExpressionHandler(
|
||||
.build()
|
||||
|
||||
override fun evaluate(expression: String, context: PlaceholderContext): Double? {
|
||||
expression.fastToDoubleOrNull()?.let { return it }
|
||||
|
||||
// Peak performance (totally not having fun with bitwise operators)
|
||||
val hash = (((expression.hashCode() shl 5) - expression.hashCode()) xor
|
||||
(context.player?.uniqueId?.hashCode() ?: 0)
|
||||
|
||||
@@ -26,8 +26,10 @@ interface ExpressionHandler {
|
||||
fun evaluate(expression: String, context: PlaceholderContext): Double?
|
||||
}
|
||||
|
||||
private fun String.fastToDoubleOrNull(): Double? {
|
||||
if (isEmpty()) {
|
||||
fun String.fastToDoubleOrNull(): Double? {
|
||||
val len = length
|
||||
|
||||
if (len == 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -39,8 +41,7 @@ private fun String.fastToDoubleOrNull(): Double? {
|
||||
var decimalPart = 0.0
|
||||
var decimalIdx = -1
|
||||
|
||||
while (idx < length) {
|
||||
|
||||
while (idx < len) {
|
||||
when (val char = this[idx]) {
|
||||
'.' -> {
|
||||
if (decimalIdx != -1) return null
|
||||
@@ -62,7 +63,7 @@ private fun String.fastToDoubleOrNull(): Double? {
|
||||
idx++
|
||||
}
|
||||
|
||||
decimalPart /= 10.0.pow((length - decimalIdx - 1).toDouble())
|
||||
decimalPart /= 10.0.pow((len - decimalIdx - 1).toDouble())
|
||||
|
||||
return if (isNegative) -(integerPart + decimalPart) else integerPart + decimalPart
|
||||
}
|
||||
@@ -93,8 +94,7 @@ class ImmediatePlaceholderTranslationExpressionHandler(
|
||||
class LazyPlaceholderTranslationExpressionHandler(
|
||||
private val placeholderParser: PlaceholderParser
|
||||
) : ExpressionHandler {
|
||||
private val cache: Cache<String, CompiledExpression?> = Caffeine.newBuilder()
|
||||
.build()
|
||||
private val cache = mutableMapOf<String, CompiledExpression?>()
|
||||
|
||||
override fun evaluate(expression: String, context: PlaceholderContext): Double? {
|
||||
val placeholders = PlaceholderManager.findPlaceholdersIn(expression)
|
||||
@@ -103,7 +103,7 @@ class LazyPlaceholderTranslationExpressionHandler(
|
||||
.map { it.fastToDoubleOrNull() ?: 0.0 }
|
||||
.toDoubleArray()
|
||||
|
||||
val compiled = cache.get(expression) {
|
||||
val compiled = cache.getOrPut(expression) {
|
||||
val env = EvaluationEnvironment()
|
||||
env.setVariableNames(*placeholders.toTypedArray())
|
||||
env.addFunctions(min, max)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version = 6.63.1
|
||||
version = 6.65.3
|
||||
plugin-name = eco
|
||||
kotlin.code.style = official
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
6
gradlew
vendored
6
gradlew
vendored
@@ -205,6 +205,12 @@ set -- \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
||||
14
gradlew.bat
vendored
14
gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@@ -25,7 +25,7 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user