mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
remove legacy plugin and server versions from gradlew
This commit is contained in:
parent
93a87cfdf1
commit
a8524fd8c8
46 changed files with 0 additions and 888 deletions
|
|
@ -0,0 +1,38 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.datapack
|
||||
|
||||
import io.papermc.paper.datapack.Datapack
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.packs.DataPack
|
||||
import java.util.*
|
||||
|
||||
object DataPackTester {
|
||||
val legacyNames: List<String>
|
||||
get() = Bukkit.getDataPackManager().dataPacks
|
||||
.stream().filter { obj -> obj.isEnabled }
|
||||
.map { pack -> pack.key.key }
|
||||
.toList()
|
||||
|
||||
val enabledPacks: List<String>
|
||||
get() {
|
||||
try {
|
||||
// will throw error if do not exist
|
||||
Bukkit::class.java.getDeclaredMethod("getDatapackManager")
|
||||
|
||||
return Bukkit.getDatapackManager().enabledPacks
|
||||
.stream().map { obj: Datapack -> obj.name }
|
||||
.toList()
|
||||
} catch (e: NoSuchMethodException) {
|
||||
try {
|
||||
DataPack::class.java.getDeclaredMethod("getKey")
|
||||
} catch (e: NoSuchMethodException) {
|
||||
System.err.println("Could not find compatible datapack manager")
|
||||
System.err.println("If you are using a datapack that should be compatible with CustomAnvil. It will not get detected...")
|
||||
return emptyList()
|
||||
}
|
||||
return legacyNames
|
||||
} catch (e: Exception){
|
||||
// Assume cause UnimplementedOperationException on mock server
|
||||
return Collections.emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.scheduler
|
||||
|
||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.entity.Entity
|
||||
import org.bukkit.plugin.Plugin
|
||||
import java.util.function.Consumer
|
||||
|
||||
class FoliaScheduler : TaskScheduler {
|
||||
override fun scheduleGlobally(plugin: Plugin, task: Runnable, time: Long): Any? {
|
||||
if(time < 1){
|
||||
return Bukkit.getGlobalRegionScheduler().run(
|
||||
plugin
|
||||
) { scheduledTask: ScheduledTask? -> task.run() }
|
||||
}
|
||||
return Bukkit.getGlobalRegionScheduler().runDelayed(
|
||||
plugin,
|
||||
{ scheduledTask: ScheduledTask? -> task.run() },
|
||||
time
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
override fun scheduleOnEntity(plugin: Plugin, entity: Entity, task: Runnable, time: Long): Any? {
|
||||
if(time < 1){
|
||||
return entity.scheduler.run(
|
||||
plugin,
|
||||
{ scheduledTask: ScheduledTask? -> task.run() },
|
||||
{}
|
||||
)
|
||||
}
|
||||
return entity.scheduler.runDelayed(
|
||||
plugin,
|
||||
{ scheduledTask: ScheduledTask? -> task.run() },
|
||||
{},
|
||||
time
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue