extensions + velocity api
This commit is contained in:
parent
549f897013
commit
f2d5ec919a
9 changed files with 227 additions and 9 deletions
|
@ -11,6 +11,8 @@
|
|||
<option value="$PROJECT_DIR$/api" />
|
||||
<option value="$PROJECT_DIR$/code-gen" />
|
||||
<option value="$PROJECT_DIR$/common" />
|
||||
<option value="$PROJECT_DIR$/kotlin" />
|
||||
<option value="$PROJECT_DIR$/kotlin/kotlin-extensions-spigot" />
|
||||
<option value="$PROJECT_DIR$/platforms" />
|
||||
<option value="$PROJECT_DIR$/platforms/spigot" />
|
||||
<option value="$PROJECT_DIR$/test-plugin" />
|
||||
|
|
|
@ -5,15 +5,10 @@
|
|||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="9d5d9b6f-43c8-41a4-bb42-a66ffc96c9b0" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/testentitylib/TestTextDisplayCommand.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/code-gen/src/main/java/me/tofaa/entitylib/codegen/modern/Main.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/kotlin/kotlin-extensions-spigot/src/main/kotlin/me/tofaa/entitylib/kotlin/EntityExtensions.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityLibAPI.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityLibAPI.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/ExtraConversionUtil.java" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/ExtraConversionUtil.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/InternalRegistryListener.java" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/InternalRegistryListener.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/settings.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/settings.gradle" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -66,6 +61,7 @@
|
|||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="Class" />
|
||||
<option value="Kotlin Class" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
@ -73,6 +69,8 @@
|
|||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="HighlightingSettingsPerFile">
|
||||
<setting file="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.github.retrooper.packetevents/api/2.2.1/5aea4193d2dadf2f99523ded56a910c4dd98d23f/api-2.2.1-default.jar!/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerEntityAnimation.class" root0="SKIP_INSPECTION" />
|
||||
<setting file="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.github.retrooper.packetevents/api/2.2.1/5aea4193d2dadf2f99523ded56a910c4dd98d23f/api-2.2.1-default.jar!/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSystemChatMessage.class" root0="SKIP_INSPECTION" />
|
||||
<setting file="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.github.retrooper.packetevents/spigot/2.0.2/e1b5c8968213460b6bcf919597ea94de2157cb31/spigot-2.0.2.jar!/com/github/retrooper/packetevents/event/PacketListenerCommon.class" root0="SKIP_INSPECTION" />
|
||||
<setting file="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.spigotmc/spigot-api/1.20.1-R0.1-SNAPSHOT/23c0dae3633c3dd31d4503969fa7f9f3d36840fb/spigot-api-1.20.1-R0.1-SNAPSHOT.jar!/org/bukkit/plugin/EventExecutor.class" root0="SKIP_INSPECTION" />
|
||||
<setting file="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.spigotmc/spigot-api/1.20.1-R0.1-SNAPSHOT/23c0dae3633c3dd31d4503969fa7f9f3d36840fb/spigot-api-1.20.1-R0.1-SNAPSHOT.jar!/org/bukkit/plugin/PluginManager.class" root0="SKIP_INSPECTION" />
|
||||
|
@ -318,6 +316,7 @@
|
|||
<workItem from="1708550708196" duration="523000" />
|
||||
<workItem from="1708591139716" duration="1553000" />
|
||||
<workItem from="1708597333736" duration="3637000" />
|
||||
<workItem from="1708679023133" duration="5295000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package me.tofaa.entitylib.codegen.modern;
|
||||
|
||||
public final class Main {
|
||||
|
||||
private Main() {}
|
||||
|
||||
}
|
13
kotlin/kotlin-extensions-spigot/build.gradle
Normal file
13
kotlin/kotlin-extensions-spigot/build.gradle
Normal file
|
@ -0,0 +1,13 @@
|
|||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.9.22'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":platforms:spigot"))
|
||||
compileOnly('com.github.retrooper.packetevents:spigot:2.0.2')
|
||||
compileOnly('org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT')
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(8)
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package me.tofaa.entitylib.kotlin
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper
|
||||
import io.github.retrooper.packetevents.util.SpigotConversionUtil
|
||||
import me.tofaa.entitylib.EntityLib
|
||||
import me.tofaa.entitylib.EntityLibAPI
|
||||
import me.tofaa.entitylib.Platform
|
||||
import me.tofaa.entitylib.spigot.SpigotEntityLibAPI
|
||||
import me.tofaa.entitylib.wrapper.WrapperEntity
|
||||
import me.tofaa.entitylib.wrapper.WrapperEntityEquipment
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.entity.Entity
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.plugin.java.JavaPlugin
|
||||
|
||||
fun JavaPlugin.getEntityLibApi(): EntityLibAPI<SpigotEntityLibAPI> {
|
||||
return EntityLib.getApi<SpigotEntityLibAPI>()!!
|
||||
}
|
||||
|
||||
fun JavaPlugin.getEntityLibPlatform(): Platform<*> {
|
||||
return EntityLib.getPlatform()!!
|
||||
}
|
||||
|
||||
fun WrapperEntity.asBukkitEntity(location: Location): Entity {
|
||||
val world = location.world ?: throw IllegalArgumentException("Location world is null");
|
||||
val entity = world.spawnEntity(location, SpigotConversionUtil.toBukkitEntityType(this.entityType));
|
||||
// TODO: Copy entity data
|
||||
return entity;
|
||||
}
|
||||
|
||||
fun WrapperEntity.sendPacketToViewersAndCallback(packet: PacketWrapper<*>, callback: () -> Unit) {
|
||||
this.sendPacketsToViewers(packet);
|
||||
callback();
|
||||
}
|
||||
|
||||
fun WrapperEntity.sendPacketsToViewersAndCallback(vararg packets: PacketWrapper<*>, callback: () -> Unit) {
|
||||
this.sendPacketsToViewers(*packets);
|
||||
callback();
|
||||
}
|
||||
|
||||
fun Entity.asWrapperEntity(location: Location): WrapperEntity {
|
||||
return EntityLib.getApi<SpigotEntityLibAPI>().cloneEntity(this, SpigotConversionUtil.fromBukkitLocation(location));
|
||||
}
|
||||
|
||||
fun Entity.asWrapperEntity(): WrapperEntity {
|
||||
return asWrapperEntity(this.location);
|
||||
}
|
||||
|
||||
fun WrapperEntityEquipment.setMainHand(stack: ItemStack) {
|
||||
this.mainHand = SpigotConversionUtil.fromBukkitItemStack(stack);
|
||||
}
|
||||
|
||||
fun WrapperEntityEquipment.setOffHand(stack: ItemStack) {
|
||||
this.offhand = SpigotConversionUtil.fromBukkitItemStack(stack);
|
||||
}
|
||||
|
||||
fun WrapperEntityEquipment.setHelmet(stack: ItemStack) {
|
||||
this.helmet = SpigotConversionUtil.fromBukkitItemStack(stack);
|
||||
}
|
||||
|
||||
fun WrapperEntityEquipment.setChestplate(stack: ItemStack) {
|
||||
this.chestplate = SpigotConversionUtil.fromBukkitItemStack(stack);
|
||||
}
|
||||
|
||||
fun WrapperEntityEquipment.setLeggings(stack: ItemStack) {
|
||||
this.leggings = SpigotConversionUtil.fromBukkitItemStack(stack);
|
||||
}
|
||||
|
||||
fun WrapperEntityEquipment.setBoots(stack: ItemStack) {
|
||||
this.boots = SpigotConversionUtil.fromBukkitItemStack(stack);
|
||||
}
|
20
platforms/velocity/build.gradle
Normal file
20
platforms/velocity/build.gradle
Normal file
|
@ -0,0 +1,20 @@
|
|||
|
||||
repositories {
|
||||
maven {
|
||||
name = 'papermc'
|
||||
url = 'https://repo.papermc.io/repository/maven-public/'
|
||||
}
|
||||
}
|
||||
tasks {
|
||||
compileJava {
|
||||
options.release.set(17)
|
||||
}
|
||||
}
|
||||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
|
||||
|
||||
dependencies {
|
||||
api(project(":common"))
|
||||
compileOnly('com.github.retrooper.packetevents:velocity:2.0.2')
|
||||
compileOnly 'com.velocitypowered:velocity-api:3.3.0-SNAPSHOT'
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package me.tofaa.entitylib.velocity;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.world.Location;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.scheduler.ScheduledTask;
|
||||
import me.tofaa.entitylib.APIConfig;
|
||||
import me.tofaa.entitylib.Platform;
|
||||
import me.tofaa.entitylib.common.AbstractEntityLibAPI;
|
||||
import me.tofaa.entitylib.tick.TickContainer;
|
||||
import me.tofaa.entitylib.wrapper.WrapperEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class VelocityEntityLibAPI extends AbstractEntityLibAPI<ProxyServer, ScheduledTask> {
|
||||
|
||||
|
||||
public VelocityEntityLibAPI(VelocityEntityLibPlatform platform, APIConfig settings) {
|
||||
super(platform, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTickContainer(@NotNull TickContainer tickContainer) {
|
||||
if (!settings.shouldTickTickables()) {
|
||||
if (settings.isDebugMode()) {
|
||||
platform.getLogger().log(Level.WARNING, "Tried to add a TickContainer when ticking tickables is disabled!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
tickContainers.add(tickContainer);
|
||||
if (settings.isDebugMode()) {
|
||||
platform.getLogger().log(Level.CONFIG, "Registering new tick container...");
|
||||
}
|
||||
getTickContainers().add(tickContainer);
|
||||
Object plugin = ((VelocityEntityLibPlatform)platform).getPlugin();
|
||||
ScheduledTask task = platform.getHandle().getScheduler().buildTask(plugin, () -> tickContainer.tick(System.currentTimeMillis())).repeat(50L, TimeUnit.MILLISECONDS).schedule();
|
||||
tickContainer.setHandle(task);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public WrapperEntity cloneEntity(@NotNull Object platformEntity, @NotNull Location location) {
|
||||
throw new UnsupportedOperationException("No support for cloning entities on Velocity");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package me.tofaa.entitylib.velocity;
|
||||
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import me.tofaa.entitylib.APIConfig;
|
||||
import me.tofaa.entitylib.EntityLibAPI;
|
||||
import me.tofaa.entitylib.common.AbstractPlatform;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class VelocityEntityLibPlatform extends AbstractPlatform<ProxyServer> {
|
||||
private VelocityEntityLibAPI api;
|
||||
private Object plugin;
|
||||
|
||||
public VelocityEntityLibPlatform(Object plugin, ProxyServer handle) {
|
||||
super(handle);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupApi(@NotNull APIConfig settings) {
|
||||
super.setupApi(settings);
|
||||
this.logger = Logger.getLogger("EntityLib"); // Velocity does not have a logger by default.
|
||||
this.api = new VelocityEntityLibAPI(this, settings);
|
||||
this.api.onLoad();
|
||||
this.api.onEnable();
|
||||
}
|
||||
|
||||
public Object getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityLibAPI<?> getAPI() {
|
||||
return api;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Velocity";
|
||||
}
|
||||
}
|
|
@ -1,3 +1,6 @@
|
|||
plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
|
||||
}
|
||||
rootProject.name = 'EntityLib'
|
||||
//include 'test-plugin'
|
||||
include 'api'
|
||||
|
@ -8,4 +11,9 @@ include 'code-gen'
|
|||
|
||||
if (!Boolean.parseBoolean(System.getenv("JITPACK"))) {
|
||||
include 'test-plugin'
|
||||
}
|
||||
}
|
||||
include 'kotlin:kotlin-extensions-spigot'
|
||||
findProject(':kotlin:kotlin-extensions-spigot')?.name = 'kotlin-extensions-spigot'
|
||||
include 'platforms:velocity'
|
||||
findProject(':platforms:velocity')?.name = 'velocity'
|
||||
|
||||
|
|
Loading…
Reference in a new issue