Compare commits

..

9 Commits

Author SHA1 Message Date
Auxilor
8fa209a981 Switched from shallow to deep packet cloning for async 2022-01-18 09:19:14 +00:00
Auxilor
b3a0634ad0 Updated to 6.20.3 2022-01-18 09:18:36 +00:00
Auxilor
97d7acc0a9 Tweaked async display 2022-01-18 09:18:25 +00:00
Auxilor
ebac75b0ee Updated to 6.20.2 2022-01-18 08:41:04 +00:00
Auxilor
02d0fa85b5 Updated plugin.yml 2022-01-18 08:40:53 +00:00
Auxilor
168915868c Added support for CustomCrafting and ExecutableItems 2022-01-18 08:40:38 +00:00
Auxilor
d62d598fd6 Merge branch '0ft3n_master' into develop
# Conflicts:
#	eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt
2022-01-18 08:38:53 +00:00
0ft3n
06561c5387 Removed unneeded event call 2022-01-18 02:00:10 +03:00
often
c0547a7c34 Readded and fixed CustomItems support, added ExecutableItems support 2022-01-02 13:19:35 +03:00
10 changed files with 100 additions and 19 deletions

View File

@@ -73,12 +73,10 @@ open class EcoDropQueue(val player: Player) : InternalDropQueue {
world.dropItem(location, drop!!).velocity = Vector()
}
if (xp > 0) {
val event = PlayerExpChangeEvent(player, xp)
Bukkit.getPluginManager().callEvent(event)
val orb =
world.spawnEntity(player.location.add(0.0, 0.2, 0.0), EntityType.EXPERIENCE_ORB) as ExperienceOrb
orb.velocity = Vector(0, 0, 0)
orb.experience = event.amount
orb.experience = xp
}
} else {
for (drop in items) {
@@ -94,4 +92,4 @@ open class EcoDropQueue(val player: Player) : InternalDropQueue {
init {
location = player.location
}
}
}

View File

@@ -26,6 +26,7 @@ dependencies {
compileOnly 'com.gmail.nossr50.mcMMO:mcMMO:2.1.202'
compileOnly 'me.clip:placeholderapi:2.10.10'
compileOnly 'com.github.oraxen:oraxen:bd81ace154'
compileOnly 'com.github.Ssomar-Developement:ExecutableItems:master-SNAPSHOT'
compileOnly 'com.github.brcdev-minecraft:shopgui-api:2.2.0'
compileOnly 'com.github.LoneDev6:API-ItemsAdder:2.4.7'
compileOnly 'com.arcaniax:HeadDatabase-API:1.3.0'

View File

@@ -84,6 +84,8 @@ import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefSuperiorSk
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefTowny
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefWorldGuard
import com.willfp.eco.internal.spigot.integrations.customentities.CustomEntitiesMythicMobs
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsCustomCrafting
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsExecutableItems
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsHeadDatabase
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsItemsAdder
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsOraxen
@@ -249,6 +251,8 @@ abstract class EcoSpigotPlugin : EcoPlugin(
IntegrationLoader("Oraxen") { CustomItemsManager.register(CustomItemsOraxen()) },
IntegrationLoader("ItemsAdder") { CustomItemsManager.register(CustomItemsItemsAdder()) },
IntegrationLoader("HeadDatabase") { CustomItemsManager.register(CustomItemsHeadDatabase(this)) },
IntegrationLoader("ExecutableItems") { CustomItemsManager.register(CustomItemsExecutableItems()) },
IntegrationLoader("CustomCrafting") { CustomItemsManager.register(CustomItemsCustomCrafting()) },
// Shop
IntegrationLoader("ShopGUIPlus") { ShopManager.register(ShopShopGuiPlus()) },

View File

@@ -6,6 +6,7 @@ import com.comphenix.protocol.events.PacketContainer
import com.comphenix.protocol.events.PacketEvent
import com.google.common.util.concurrent.ThreadFactoryBuilder
import com.willfp.eco.core.AbstractPacketAdapter
import com.willfp.eco.core.Eco
import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.display.Display
import com.willfp.eco.core.fast.FastItemStack
@@ -47,17 +48,10 @@ class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, Packe
handleRateLimit(player)
if (usingAsync(player)) {
val newPacket = packet.deepClone()
executor.execute {
runCatching {
modifyAndSend(packet.shallowClone(), itemStacks, windowId, player)
}.onFailure {
if (this.getPlugin().configYml.getBool("async-display.log-errors")) {
this.getPlugin().logger.warning(
"Error happened in async processing! Disable async display (/plugins/eco/config.yml)" +
"if this is a frequent issue. (Remember to disable ratelimit and emergency too)"
)
}
}
runCatchingWithLogs { modifyAndSend(newPacket, itemStacks, windowId, player) }
}
} else {
modifyPacket(packet, itemStacks, windowId, player)
@@ -82,7 +76,7 @@ class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, Packe
modifyPacket(packet, itemStacks, windowId, player)
ignorePacketList.add(player.name)
this.getPlugin().scheduler.run {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet)
runCatchingWithLogs { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet) }
}
}
@@ -169,4 +163,15 @@ class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, Packe
return itemStacks
}
}
}
private inline fun <T> runCatchingWithLogs(toRun: () -> T): Result<T> {
return runCatching { toRun() }.onFailure {
if (Eco.getHandler().ecoPlugin.configYml.getBool("async-display.log-errors")) {
Eco.getHandler().ecoPlugin.logger.warning(
"Error happened in async processing! Disable async display (/plugins/eco/config.yml)" +
"if this is a frequent issue. (Remember to disable ratelimit and emergency too)"
)
}
}
}

View File

@@ -0,0 +1,38 @@
package com.willfp.eco.internal.spigot.integrations.customitems
import com.willfp.eco.core.integrations.customitems.CustomItemsWrapper
import com.willfp.eco.core.items.CustomItem
import com.willfp.eco.core.items.Items
import com.willfp.eco.core.items.TestableItem
import com.willfp.eco.core.items.provider.ItemProvider
import com.willfp.eco.util.NamespacedKeyUtils
import me.wolfyscript.utilities.util.NamespacedKey
import me.wolfyscript.utilities.util.Registry
import org.bukkit.inventory.ItemStack
import java.util.function.Predicate
class CustomItemsCustomCrafting: CustomItemsWrapper {
override fun registerAllItems() {
Items.registerItemProvider(CustomCraftingProvider())
}
override fun getPluginName(): String {
return "CustomCrafting"
}
private class CustomCraftingProvider : ItemProvider("customcrafting") {
override fun provideForKey(key: String): TestableItem? {
val nKey = key.replace("customcrafting:", "", ignoreCase = true)
val itemKey = NamespacedKey("customcrafting", nKey)
val item = Registry.CUSTOM_ITEMS.get(itemKey) ?: return null
val namespacedKey = NamespacedKeyUtils.create("customcrafting", key)
val stack = item.create(1)
return CustomItem(
namespacedKey,
Predicate { test: ItemStack ->
val customStack = me.wolfyscript.utilities.api.inventory.custom_items.CustomItem.getByItemStack(test) ?: return@Predicate false
val iKey = customStack.namespacedKey ?: return@Predicate false
iKey.equals(key)
},
stack
)
}
}
}

View File

@@ -0,0 +1,33 @@
package com.willfp.eco.internal.spigot.integrations.customitems
import com.ssomar.score.api.ExecutableItemsAPI
import com.willfp.eco.core.integrations.customitems.CustomItemsWrapper
import com.willfp.eco.core.items.CustomItem
import com.willfp.eco.core.items.Items
import com.willfp.eco.core.items.TestableItem
import com.willfp.eco.core.items.provider.ItemProvider
import com.willfp.eco.util.NamespacedKeyUtils
import org.bukkit.inventory.ItemStack
import java.util.function.Predicate
class CustomItemsExecutableItems: CustomItemsWrapper {
override fun registerAllItems() {
Items.registerItemProvider(ExecutableItemsProvider())
}
override fun getPluginName(): String {
return "ExecutableItems"
}
private class ExecutableItemsProvider : ItemProvider("executableitems") {
override fun provideForKey(key: String): TestableItem? {
val item = ExecutableItemsAPI.getExecutableItem(key) ?: return null
val namespacedKey = NamespacedKeyUtils.create("executableitems", key)
return CustomItem(
namespacedKey,
Predicate { test: ItemStack ->
val customStack = ExecutableItemsAPI.getExecutableItemConfig(test) ?: return@Predicate false
customStack.id.equals(key, ignoreCase = true)
},
item
)
}
}
}

View File

@@ -69,14 +69,14 @@ async-display:
# If emergency async should be used.
enabled: true
# Below this TPS value, emergency async display will be used.
cutoff: 18
cutoff: 17
# If players with a large amount of display packets should have their processing
# done asynchronously. This will help if a player is trying to crash the server
# by overloading the display system.
ratelimit:
# If rate limit async display should be used.
enabled: true
enabled: false
# The amount of window items packets per timeframe needed to enable async display
# for a specified player.
cutoff: 4

View File

@@ -40,6 +40,8 @@ softdepend:
- CrashClaim
- DecentHolograms
- MythicMobs
- CustomCrafting
- ExecutableItems
libraries:
- 'org.reflections:reflections:0.9.12'
- 'org.apache.maven:maven-artifact:3.0.3'

View File

@@ -1,3 +1,3 @@
version = 6.20.1
version = 6.20.3
plugin-name = eco
kotlin.code.style = official

BIN
lib/SCore-1.6.0.9.jar Normal file

Binary file not shown.