diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 3ba5bd47f..88c504c32 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -55,7 +55,7 @@ jobs:
chmod +x gradlew
wget "https://jitpack.io/com/github/MilkBowl/VaultAPI/1.7/VaultAPI-1.7.jar"
mvn install:install-file -Dfile=VaultAPI-1.7.jar -DgroupId=net.milkbowlvault -DartifactId=VaultAPI -Dversion=1.7 -Dpackaging=jar
- ./gradlew build pluginJar
+ ./gradlew build pluginJars
echo "RELEASE_VERSION=$(./gradlew -q printVersion)" >> $GITHUB_ENV
- name: Create Github Release
@@ -78,24 +78,19 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
- asset_path: /home/runner/work/BlockBall/BlockBall/blockball-bukkit-plugin/build/libs/blockball-bukkit-plugin-${{ env.RELEASE_VERSION }}.jar
+ asset_path: /home/runner/work/BlockBall/BlockBall/blockball-bukkit-plugin/build/libs/blockball-bukkit-plugin-${{ env.RELEASE_VERSION }}-latest.jar
asset_name: BlockBall.jar
asset_content_type: application/jar
- - name: Build Java Application with all flag
- run: |
- sed -i "s/###VERSION###/all/g" ./blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/BlockBallPlugin.kt
- ./gradlew build pluginJar
-
- - name: Upload All Bukkit Release to Github
+ - name: Upload Legacy Bukkit Release to Github
if: "contains(github.event.head_commit.message, '--release') && contains(github.ref, 'master')"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
- asset_path: /home/runner/work/BlockBall/BlockBall/blockball-bukkit-plugin/build/libs/blockball-bukkit-plugin-${{ env.RELEASE_VERSION }}.jar
- asset_name: BlockBall-All.jar
+ asset_path: /home/runner/work/BlockBall/BlockBall/blockball-bukkit-plugin/build/libs/blockball-bukkit-plugin-${{ env.RELEASE_VERSION }}-legacy.jar
+ asset_name: BlockBall-Legacy.jar
asset_content_type: application/jar
Documentation:
diff --git a/Dockerfile b/Dockerfile
index af8e1b3d1..faad9c379 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -18,13 +18,7 @@ RUN yum install maven -y
RUN yum install wget -y
RUN yum install git -y
RUN wget "https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar"
-RUN java -jar BuildTools.jar --rev 1.17.1 --remapped
-RUN java -jar BuildTools.jar --rev 1.18 --remapped
-RUN java -jar BuildTools.jar --rev 1.18.2 --remapped
-RUN java -jar BuildTools.jar --rev 1.19 --remapped
-RUN java -jar BuildTools.jar --rev 1.19.3 --remapped
-RUN java -jar BuildTools.jar --rev 1.19.4 --remapped
-RUN java -jar BuildTools.jar --rev 1.20.1 --remapped
+RUN java -jar BuildTools.jar --rev 1.20.2 --remapped
# 3. Build plugin for 1.8 - latest with jdk17
FROM amazoncorretto:17 AS plugin-jdk17
@@ -43,7 +37,7 @@ RUN ./gradlew build pluginJar --no-daemon
# 4. Launch a minecraft server with jdk17 and plugin
FROM amazoncorretto:17
# Change to the current plugin version present in build.gradle
-ENV PLUGIN_VERSION=6.34.2
+ENV PLUGIN_VERSION=6.35.0
# Change to the server version you want to test.
ENV SERVER_VERSION=spigot-1.18.jar
# Port of the Minecraft Server.
diff --git a/README.md b/README.md
index 1e67dc2fc..7b2a85fa9 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ BlockBall is a spigot plugin to play soccer games in Minecraft.
* Uses blocks as balls in minecraft
* Games are completely customizable
-* Version support 1.8.R3 - 1.20.R1
+* Version support 1.8.R3 - 1.20.R2
* Check out the [BlockBall-Spigot-Page](https://www.spigotmc.org/resources/15320/) to get more information.
## Installation
@@ -31,7 +31,7 @@ BlockBall is a spigot plugin to play soccer games in Minecraft.
* Install Java 17 or higher
* Fork the BlockBall project on github and clone it to your local environment.
-* BlockBall requires spigot server implementations from 1.16 to 1.20 to be correctly installed in your local Maven cache.
+* BlockBall requires multiple spigot versions to be correctly installed in your local Maven cache.
As this requires multiple java version to build different versions, a Dockerfile is provided to build these dependencies in a docker container
and then copy it to your local Maven cache.
diff --git a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/enumeration/ParticleType.kt b/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/enumeration/ParticleType.kt
index ce301aa14..95ed3baf8 100644
--- a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/enumeration/ParticleType.kt
+++ b/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/enumeration/ParticleType.kt
@@ -40,231 +40,226 @@ enum class ParticleType(
/**
* Minecraft Id for 1.12.
*/
- val minecraftId_112: String,
-
- /**
- * Version where this effect was added.
- */
- val sinceVersion: Version) {
+ val minecraftId_112: String) {
/**
* No Particle.
*/
- NONE("none", "none", "none", Version.VERSION_1_8_R1),
+ NONE("none", "none", "none"),
/**
* Explosion.
*/
- EXPLOSION_NORMAL("explode", "poof", "explosion", Version.VERSION_1_8_R1),
+ EXPLOSION_NORMAL("explode", "poof", "explosion"),
/**
* Large explosion.
*/
- EXPLOSION_LARGE("largeexplode", "explosion", "large_explosion", Version.VERSION_1_8_R1),
+ EXPLOSION_LARGE("largeexplode", "explosion", "large_explosion"),
/**
* Huge explosion.
*/
- EXPLOSION_HUGE("hugeexplosion", "explosion_emitter", "huge_explosion", Version.VERSION_1_8_R1),
+ EXPLOSION_HUGE("hugeexplosion", "explosion_emitter", "huge_explosion"),
/**
* Firework.
*/
- FIREWORKS_SPARK("fireworksSpark", "firework", "fireworks_spark", Version.VERSION_1_8_R1),
+ FIREWORKS_SPARK("fireworksSpark", "firework", "fireworks_spark"),
/**
* Water Bubble simple.
*/
- WATER_BUBBLE("bubble", "bubble", "water_bubble", Version.VERSION_1_8_R1),
+ WATER_BUBBLE("bubble", "bubble", "water_bubble"),
/**
* Water Bubble up.
*/
- WATER_BUBBLE_UP("bubble_column_up", "bubble_column_up", "bubble_column_up", Version.VERSION_1_13_R1),
+ WATER_BUBBLE_UP("bubble_column_up", "bubble_column_up", "bubble_column_up"),
/**
* Water Bubble pop.
*/
- WATER_BUBBLE_POP("bubble_pop", "bubble_pop", "bubble_pop", Version.VERSION_1_13_R1),
+ WATER_BUBBLE_POP("bubble_pop", "bubble_pop", "bubble_pop"),
/**
* Water Splash.
*/
- WATER_SPLASH("splash", "splash", "water_splash", Version.VERSION_1_8_R1),
+ WATER_SPLASH("splash", "splash", "water_splash"),
/**
* Fishing effect.
*/
- WATER_WAKE("wake", "fishing", "water_wake", Version.VERSION_1_8_R1),
+ WATER_WAKE("wake", "fishing", "water_wake"),
/**
* Underwater bubbles.
*/
- SUSPENDED("suspended", "underwater", "suspended", Version.VERSION_1_8_R1),
+ SUSPENDED("suspended", "underwater", "suspended"),
/**
* Unused effect.
*/
- SUSPENDED_DEPTH("depthsuspend", "depthsuspend", "suspended_depth", Version.VERSION_1_8_R1),
+ SUSPENDED_DEPTH("depthsuspend", "depthsuspend", "suspended_depth"),
/**
* Critical damage.
*/
- CRIT("crit", "crit", "critical_hit", Version.VERSION_1_8_R1),
+ CRIT("crit", "crit", "critical_hit"),
/**
* Critical magical damage.
*/
- CRIT_MAGIC("magicCrit", "enchanted_hit", "magic_critical_hit", Version.VERSION_1_8_R1),
+ CRIT_MAGIC("magicCrit", "enchanted_hit", "magic_critical_hit"),
/**
* Water effect.
*/
- CURRENTDOWN("current_down", "current_down", "current_down", Version.VERSION_1_13_R1),
+ CURRENTDOWN("current_down", "current_down", "current_down"),
/**
* Smoke.
*/
- SMOKE_NORMAL("smoke", "smoke", "smoke", Version.VERSION_1_8_R1),
+ SMOKE_NORMAL("smoke", "smoke", "smoke"),
/**
* Large Smoke.
*/
- SMOKE_LARGE("largesmoke", "large_smoke", "large_smoke", Version.VERSION_1_8_R1),
+ SMOKE_LARGE("largesmoke", "large_smoke", "large_smoke"),
/**
* Spell.
*/
- SPELL("spell", "effect", "spell", Version.VERSION_1_8_R1),
+ SPELL("spell", "effect", "spell"),
/**
* Instant Spell.
*/
- SPELL_INSTANT("instantSpell", "instant_effect", "instant_spell", Version.VERSION_1_8_R1),
+ SPELL_INSTANT("instantSpell", "instant_effect", "instant_spell"),
/**
* Mob Spell.
*/
- SPELL_MOB("mobSpell", "entity_effect", "instant_spell", Version.VERSION_1_8_R1),
+ SPELL_MOB("mobSpell", "entity_effect", "instant_spell"),
/**
* Mob Ambient Spell.
*/
- SPELL_MOB_AMBIENT("mobSpellAmbient", "mob_spell", "mob_spell", Version.VERSION_1_8_R1),
+ SPELL_MOB_AMBIENT("mobSpellAmbient", "mob_spell", "mob_spell"),
/**
* Witch Spell.
*/
- SPELL_WITCH("witchMagic", "witch", "witch_spell", Version.VERSION_1_8_R1),
+ SPELL_WITCH("witchMagic", "witch", "witch_spell"),
/**
* Drip water.
*/
- DRIP_WATER("dripWater", "dripping_water", "drip_water", Version.VERSION_1_8_R1),
+ DRIP_WATER("dripWater", "dripping_water", "drip_water"),
/**
* Drip lava.
*/
- DRIP_LAVA("dripLava", "dripping_lava", "drip_lava", Version.VERSION_1_8_R1),
+ DRIP_LAVA("dripLava", "dripping_lava", "drip_lava"),
/**
* Angry villager.
*/
- VILLAGER_ANGRY("angryVillager", "angry_villager", "angry_villager", Version.VERSION_1_8_R1),
+ VILLAGER_ANGRY("angryVillager", "angry_villager", "angry_villager"),
/**
* Happy villager.
*/
- VILLAGER_HAPPY("happyVillager", "happy_villager", "happy_villager", Version.VERSION_1_8_R1),
+ VILLAGER_HAPPY("happyVillager", "happy_villager", "happy_villager"),
/**
* Mycelium.
*/
- TOWN_AURA("townaura", "mycelium", "town_aura", Version.VERSION_1_8_R1),
+ TOWN_AURA("townaura", "mycelium", "town_aura"),
/**
* Note..
*/
- NOTE("note", "note", "note", Version.VERSION_1_8_R1),
+ NOTE("note", "note", "note"),
/**
* Portal.
*/
- PORTAL("portal", "portal", "portal", Version.VERSION_1_8_R1),
+ PORTAL("portal", "portal", "portal"),
/**
* Nautilus.
*/
- NAUTILUS("nautilus", "nautilus", "nautilus", Version.VERSION_1_13_R1),
+ NAUTILUS("nautilus", "nautilus", "nautilus"),
/**
* Enchantment.
*/
- ENCHANTMENT_TABLE("enchantmenttable", "enchant", "enchanting_glyphs", Version.VERSION_1_8_R1),
+ ENCHANTMENT_TABLE("enchantmenttable", "enchant", "enchanting_glyphs"),
/**
* Flame.
*/
- FLAME("flame", "flame", "flame", Version.VERSION_1_8_R1),
+ FLAME("flame", "flame", "flame"),
/**
* Lava.
*/
- LAVA("lava", "lava", "lava", Version.VERSION_1_8_R1),
+ LAVA("lava", "lava", "lava"),
/**
* Squid.
*/
- SQUID_INK("squid_ink", "squid_ink", "squid_ink", Version.VERSION_1_13_R1),
+ SQUID_INK("squid_ink", "squid_ink", "squid_ink"),
/**
* Footstep.
*/
- FOOTSTEP("footstep", "footstep", "footstep", Version.VERSION_1_8_R1),
+ FOOTSTEP("footstep", "footstep", "footstep"),
/**
* Cloud.
*/
- CLOUD("cloud", "cloud", "cloud", Version.VERSION_1_8_R1),
+ CLOUD("cloud", "cloud", "cloud"),
/**
* Redstone.
*/
- REDSTONE("reddust", "dust", "redstone_dust", Version.VERSION_1_8_R1),
+ REDSTONE("reddust", "dust", "redstone_dust"),
/**
* Snowball.
*/
- SNOWBALL("snowballpoof", "item_snowball", "snowball", Version.VERSION_1_8_R1),
+ SNOWBALL("snowballpoof", "item_snowball", "snowball"),
/**
* Snowshovel.
*/
- SNOW_SHOVEL("snowshovel", "snowshovel", "snow_shovel", Version.VERSION_1_8_R1),
+ SNOW_SHOVEL("snowshovel", "snowshovel", "snow_shovel"),
/**
* Slime.
*/
- SLIME("slime", "item_slime", "slime", Version.VERSION_1_8_R1),
+ SLIME("slime", "item_slime", "slime"),
/**
* Heart.
*/
- HEART("heart", "heart", "heart", Version.VERSION_1_8_R1),
+ HEART("heart", "heart", "heart"),
/**
* Barrier.
*/
- BARRIER("barrier", "barrier", "barrier", Version.VERSION_1_8_R1),
+ BARRIER("barrier", "barrier", "barrier"),
/**
* ItemCrack.
*/
- ITEM_CRACK("iconcrack", "item", "item_crack", Version.VERSION_1_8_R1),
+ ITEM_CRACK("iconcrack", "item", "item_crack"),
/**
* BlockCrack.
*/
- BLOCK_CRACK("blockcrack", "block", "block_crack", Version.VERSION_1_8_R1),
+ BLOCK_CRACK("blockcrack", "block", "block_crack"),
/**
* Blockdust.
*/
- BLOCK_DUST("blockdust", "block", "block_dust", Version.VERSION_1_8_R1),
+ BLOCK_DUST("blockdust", "block", "block_dust"),
/**
* Rain.
*/
- WATER_DROP("droplet", "rain", "water_drop", Version.VERSION_1_8_R1),
+ WATER_DROP("droplet", "rain", "water_drop"),
/**
* Unknown.
*/
- TEM_TAKE("take", "take", "instant_spell", Version.VERSION_1_8_R1),
+ TEM_TAKE("take", "take", "instant_spell"),
/**
* Guardian scare.
*/
- MOB_APPEARANCE("mobappearance", "elder_guardian", "guardian_appearance", Version.VERSION_1_8_R1),
+ MOB_APPEARANCE("mobappearance", "elder_guardian", "guardian_appearance"),
/**
* Dragon Breath.
*/
- DRAGON_BREATH("dragonbreath", "dragon_breath", "dragon_breath", Version.VERSION_1_9_R1),
+ DRAGON_BREATH("dragonbreath", "dragon_breath", "dragon_breath"),
/**
* End rod.
*/
- END_ROD("endRod", "end_rod", "end_rod", Version.VERSION_1_9_R1),
+ END_ROD("endRod", "end_rod", "end_rod"),
/**
* Damage Indicator.
*/
- DAMAGE_INDICATOR("damageIndicator", "damage_indicator", "damage_indicator", Version.VERSION_1_9_R1),
+ DAMAGE_INDICATOR("damageIndicator", "damage_indicator", "damage_indicator"),
/**
* Sweep Attack.
*/
- SWEEP_ATTACK("sweepAttack", "sweep_attack", "sweep_attack", Version.VERSION_1_9_R1),
+ SWEEP_ATTACK("sweepAttack", "sweep_attack", "sweep_attack"),
/**
* Falling Dust.
*/
- FALLING_DUST("fallingdust", "falling_dust", "falling_dust", Version.VERSION_1_10_R1),
+ FALLING_DUST("fallingdust", "falling_dust", "falling_dust"),
/**
* Totem.
*/
- TOTEM("totem", "totem_of_undying", "instant_spell", Version.VERSION_1_11_R1),
+ TOTEM("totem", "totem_of_undying", "instant_spell"),
/**
* Spit.
*/
- SPIT("spit", "spit", "instant_spell", Version.VERSION_1_11_R1);
-}
\ No newline at end of file
+ SPIT("spit", "spit", "instant_spell");
+}
diff --git a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/enumeration/Version.kt b/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/enumeration/Version.kt
deleted file mode 100644
index 12829de06..000000000
--- a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/enumeration/Version.kt
+++ /dev/null
@@ -1,163 +0,0 @@
-package com.github.shynixn.blockball.api.business.enumeration
-
-/**
- * Supported versions.
- */
-enum class Version(
- /**
- * Id of the bukkit versions.
- */
- val bukkitId: String,
- /**
- * General id.
- */
- val id: String,
- /**
- * Numeric Id for calculations.
- */
- val numericId: Double
-) {
- /**
- * Unknown version.
- */
- VERSION_UNKNOWN("", "", 0.0),
-
- /**
- * Version 1.8.0 - 1.8.2.
- */
- VERSION_1_8_R1("v1_8_R1", "1.8.2", 1.081),
-
- /**
- * Version 1.8.3 - 1.8.4.
- */
- VERSION_1_8_R2("v1_8_R2", "1.8.3", 1.082),
-
- /**
- * Version 1.8.5 - 1.8.9.
- */
- VERSION_1_8_R3("v1_8_R3", "1.8.9", 1.083),
-
- /**
- * Version 1.9.0 - 1.9.1.
- */
- VERSION_1_9_R1("v1_9_R1", "1.9.1", 1.091),
-
- /**
- * Version 1.9.2 - 1.9.4
- */
- VERSION_1_9_R2("v1_9_R2", "1.9.4", 1.092),
-
- /**
- * Version 1.10.0 - 1.10.2.
- */
- VERSION_1_10_R1("v1_10_R1", "1.10.2", 1.10),
-
- /**
- * Version 1.11.0 - 1.11.2.
- */
- VERSION_1_11_R1("v1_11_R1", "1.11.2", 1.11),
-
- /**
- * Version 1.12.0 - 1.12.2.
- */
- VERSION_1_12_R1("v1_12_R1", "1.12.2", 1.12),
-
- /**
- * Version 1.13.0 - 1.13.0.
- */
- VERSION_1_13_R1("v1_13_R1", "1.13.0", 1.13),
-
- /**
- * Version 1.13.1 - 1.13.2.
- */
- VERSION_1_13_R2("v1_13_R2", "1.13.2", 1.131),
-
- /**
- * Version 1.14.0 - 1.14.4.
- */
- VERSION_1_14_R1("v1_14_R1", "1.14.4", 1.144),
-
- /**
- * Version 1.15.0 - 1.15.2.
- */
- VERSION_1_15_R1("v1_15_R1", "1.15.2", 1.150),
-
- /**
- * Version 1.16.0 - 1.16.1.
- */
- VERSION_1_16_R1("v1_16_R1", "1.16.1", 1.160),
-
- /**
- * Version 1.16.2 - 1.16.3.
- */
- VERSION_1_16_R2("v1_16_R2", "1.16.2", 1.161),
-
- /**
- * Version 1.16.4 - 1.16.5.
- */
- VERSION_1_16_R3("v1_16_R3", "1.16.5", 1.162),
-
- /**
- * Version 1.17.0 - 1.17.1.
- */
- VERSION_1_17_R1("v1_17_R1", "1.17.0", 1.170),
-
- /**
- * Version 1.18.0 - 1.18.1.
- */
- VERSION_1_18_R1("v1_18_R1", "1.18.0", 1.180),
-
- /**
- * Version 1.18.2 - 1.18.2.
- */
- VERSION_1_18_R2("v1_18_R2", "1.18.2", 1.182),
-
- /**
- * Version 1.19.0 - 1.19.2.
- */
- VERSION_1_19_R1("v1_19_R1", "1.19.0", 1.190),
-
- /**
- * Version 1.19.3 - 1.19.3.
- */
- VERSION_1_19_R2("v1_19_R2", "1.19.3", 1.193),
-
- /**
- * Version 1.19.4 - 1.19.4.
- */
- VERSION_1_19_R3("v1_19_R3", "1.19.4", 1.194),
-
- /**
- * Version 1.20 - 1.20.
- */
- VERSION_1_20_R1("v1_20_R1", "1.20.0", 1.20);
-
- /**
- * Gets if this version is same or greater than the given version by parameter.
- */
- fun isVersionSameOrGreaterThan(version: Version): Boolean {
- val result = this.numericId.compareTo(version.numericId)
- return result == 0 || result == 1
- }
-
- /**
- * Gets if the version is the same or lower than the given version by parameter.
- */
- fun isVersionSameOrLowerThan(version: Version): Boolean {
- val result = this.numericId.compareTo(version.numericId)
- return result == 0 || result == -1
- }
-
- /**
- * Gets if this version is compatible to the versions given as parameter.
- */
- fun isCompatible(vararg versions: Version): Boolean {
- for (version in versions) {
- if (this.bukkitId == version.bukkitId) {
- return true
- }
- }
-
- return false
- }
-}
diff --git a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/proxy/PluginProxy.kt b/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/proxy/PluginProxy.kt
index 5b0be92a2..d3fa5118a 100644
--- a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/proxy/PluginProxy.kt
+++ b/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/proxy/PluginProxy.kt
@@ -1,7 +1,5 @@
package com.github.shynixn.blockball.api.business.proxy
-import com.github.shynixn.blockball.api.business.enumeration.Version
-
/**
* Created by Shynixn 2018.
*
@@ -38,7 +36,7 @@ interface PluginProxy {
/**
* Gets the server version this plugin is currently running on.
*/
- fun getServerVersion(): Version
+ fun getServerVersion(): Any
/**
* Sends a console message from this plugin.
diff --git a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/service/InternalVersionPacketService.kt b/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/service/InternalVersionPacketService.kt
deleted file mode 100644
index 024914770..000000000
--- a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/service/InternalVersionPacketService.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.github.shynixn.blockball.api.business.service
-
-import com.github.shynixn.blockball.api.business.enumeration.CompatibilityArmorSlotType
-import com.github.shynixn.blockball.api.persistence.entity.EntityMetaData
-import com.github.shynixn.blockball.api.persistence.entity.Position
-
-interface InternalVersionPacketService {
- /**
- * Creates a new teleport packet.
- */
- fun createEntityTeleportPacket(entityId: Int, position: Position): Any
-
- /**
- * Creates a spawn packet.
- */
- fun createEntitySpawnPacket(entityId: Int, entityType: String, position: Position): Any
-
- /**
- * Creates a entity metadata packet.
- */
- fun createEntityMetaDataPacket(entityId: Int, entityMetaData: EntityMetaData): Any
-
- /**
- * Creates an entity equipment packet.
- */
- fun createEntityEquipmentPacket(
- entityId: Int,
- slot: CompatibilityArmorSlotType,
- itemStack: I
- ) : Any
-}
-
diff --git a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/service/PacketService.kt b/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/service/PacketService.kt
deleted file mode 100644
index 9ac379a83..000000000
--- a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/service/PacketService.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.github.shynixn.blockball.api.business.service
-
-import com.github.shynixn.blockball.api.business.enumeration.CompatibilityArmorSlotType
-import com.github.shynixn.blockball.api.persistence.entity.EntityMetaData
-import com.github.shynixn.blockball.api.persistence.entity.Position
-
-interface PacketService {
- /**
- * Sends a velocity packet.
- */
- fun
sendEntityVelocityPacket(player: P, entityId: Int, velocity: Position)
-
- /**
- * Sends a destroy packet.
- */
- fun
sendEntityDestroyPacket(player: P, entityId: Int)
-
- /**
- * Sends a teleport packet.
- */
- fun
sendEntityTeleportPacket(player: P, entityId: Int, position: Position)
-
- /**
- * Sends a spawn packet.
- */
- fun
sendEntitySpawnPacket(player: P, entityId: Int, entityType: String, position: Position)
-
- /**
- * Sends a meta data packet.
- */
- fun
sendEntityMetaDataPacket(player: P, entityId: Int, entityMetaData: EntityMetaData)
-
- /**
- * Sends an equipment packet.
- */
- fun
sendEntityEquipmentPacket(player: P, entityId: Int, slot : CompatibilityArmorSlotType, itemStack: I)
-}
diff --git a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/service/ProtocolService.kt b/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/service/ProtocolService.kt
deleted file mode 100644
index f4b40d36c..000000000
--- a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/service/ProtocolService.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.github.shynixn.blockball.api.business.service
-
-interface ProtocolService {
- /**
- * Registers the following packets classes for events.
- */
- fun registerPackets(packets: List>)
-
- /**
- * Registers the player.
- */
- fun register(player: P)
-
- /**
- * Clears the player cache.
- */
- fun
unRegister(player: P)
-
- /**
- * Disposes the protocol service.
- */
- fun dispose()
-}
diff --git a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/PacketEvent.kt b/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/PacketEvent.kt
deleted file mode 100644
index cd6e8fa5d..000000000
--- a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/PacketEvent.kt
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.github.shynixn.blockball.api.bukkit.event
-
-import org.bukkit.entity.Player
-
-/**
- * Event when a packet from the given player arrives.
- */
-class PacketEvent(val player: Player, val packet: Any) : BlockBallEvent()
diff --git a/blockball-bukkit-plugin/build.gradle.kts b/blockball-bukkit-plugin/build.gradle.kts
index ddfdcd3ac..292e8f908 100644
--- a/blockball-bukkit-plugin/build.gradle.kts
+++ b/blockball-bukkit-plugin/build.gradle.kts
@@ -1,165 +1,117 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
-import java.net.URL
-import java.nio.file.Files
-import java.util.*
plugins {
id("com.github.johnrengelman.shadow") version ("7.0.0")
}
+tasks.withType {
+ archiveName = "${baseName}-${version}-raw.${extension}"
+}
+
+/**
+ * Include all blockball-api, blockball-bukkit-api and exclude debugging classes.
+ */
tasks.withType {
dependsOn("jar")
- archiveName = "${baseName}-${version}-mojangmapping.${extension}"
+ archiveName = "${baseName}-${version}-shadowjar.${extension}"
+ exclude("DebugProbesKt.bin")
+ exclude("module-info.class")
+}
- relocate("kotlin", "com.github.shynixn.blockball.lib.kotlin")
+/**
+ * Create all plugin jar files.
+ */
+tasks.register("pluginJars") {
+ dependsOn("pluginJarLatest")
+ dependsOn("pluginJarLegacy")
+}
+/**
+ * Create legacy plugin jar file.
+ */
+tasks.register("relocateLegacyPluginJar", ShadowJar::class.java) {
+ dependsOn("shadowJar")
+ from(zipTree(File("./build/libs/" + (tasks.getByName("shadowJar") as Jar).archiveName)))
+ archiveName = "${baseName}-${version}-legacy-relocate.${extension}"
+ relocate("kotlin", "com.github.shynixn.blockball.lib.kotlin")
relocate("org.intellij", "com.github.shynixn.blockball.lib.org.intelli")
relocate("org.jetbrains", "com.github.shynixn.blockball.lib.org.jetbrains")
- relocate("org.bstats", "com.github.shynixn.blockball.externallib.org.bstats")
+ relocate("org.bstats", "com.github.shynixn.blockball.lib.org.bstats")
relocate("javax.inject", "com.github.shynixn.blockball.lib.javax.inject")
relocate("javax.annotation", "com.github.shynixn.blockball.lib.javax.annotation")
relocate("org.checkerframework", "com.github.shynixn.blockball.lib.org.checkerframework")
relocate("org.aopalliance", "com.github.shynixn.blockball.lib.org.aopalliance")
relocate("org.slf4j", "com.github.shynixn.blockball.lib.org.slf4j")
-
relocate("com.github.shynixn.mccoroutine", "com.github.shynixn.blockball.lib.com.github.shynixn.mccoroutine")
relocate("com.google", "com.github.shynixn.blockball.lib.com.google")
relocate("com.zaxxer", "com.github.shynixn.blockball.lib.com.zaxxer")
relocate("org.apache", "com.github.shynixn.blockball.lib.org.apache")
+ relocate("com.github.shynixn.mcutils", "com.github.shynixn.blockball.lib.com.github.shynixn.mcutils")
- exclude("DebugProbesKt.bin")
- exclude("module-info.class")
+ exclude("plugin.yml")
+ rename("plugin-legacy.yml", "plugin.yml")
}
+/**
+ * Create legacy plugin jar file.
+ */
+tasks.register("pluginJarLegacy", ShadowJar::class.java) {
+ dependsOn("relocateLegacyPluginJar")
+ from(zipTree(File("./build/libs/" + (tasks.getByName("relocateLegacyPluginJar") as Jar).archiveName)))
+ archiveName = "${baseName}-${version}-legacy.${extension}"
+ // destinationDir = File("C:\\temp\\plugins")
+ exclude("kotlin/**")
+ exclude("org/**")
+ exclude("javax/**")
+ exclude("com/google/**")
+ exclude("com/github/shynixn/mcutils/**")
+ exclude("plugin-legacy.yml")
+}
-tasks.register("pluginJar", Exec::class.java) {
- // Change the output folder of the plugin.
- // val destinationDir = File("C:/temp/plugins")
- val destinationDir = File(buildDir, "libs")
+/**
+ * Create legacy plugin jar file.
+ */
+tasks.register("relocatePluginJar", ShadowJar::class.java) {
dependsOn("shadowJar")
- workingDir = buildDir
-
- if (!workingDir.exists()) {
- workingDir.mkdir();
- }
-
- val folder = File(workingDir, "mapping")
-
- if (!folder.exists()) {
- folder.mkdir()
- }
-
- val file = File(folder, "SpecialSources.jar")
-
- if (!file.exists()) {
- URL("https://repo.maven.apache.org/maven2/net/md-5/SpecialSource/1.10.0/SpecialSource-1.10.0-shaded.jar").openStream()
- .use {
- Files.copy(it, file.toPath())
- }
- }
-
- val shadowJar = tasks.findByName("shadowJar")!! as ShadowJar
- val sourceJarFile = File(buildDir, "libs/" + shadowJar.archiveName)
- val archiveName = "${shadowJar.baseName}-${shadowJar.version}.${shadowJar.extension}"
- val targetJarFile = File(destinationDir, archiveName)
-
- var obsMapping = createCommand(
- "1.17.1-R0.1-SNAPSHOT",
- "com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_17_R1",
- file,
- shadowJar,
- sourceJarFile,
- targetJarFile
- )
- obsMapping = "$obsMapping && " + createCommand(
- "1.18-R0.1-SNAPSHOT",
- "com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_18_R1",
- file,
- shadowJar,
- targetJarFile,
- targetJarFile
- )
- obsMapping = "$obsMapping && " + createCommand(
- "1.18.2-R0.1-SNAPSHOT",
- "com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_18_R2",
- file,
- shadowJar,
- targetJarFile,
- targetJarFile
- )
- obsMapping = "$obsMapping && " + createCommand(
- "1.19-R0.1-SNAPSHOT",
- "com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_19_R1",
- file,
- shadowJar,
- targetJarFile,
- targetJarFile
- )
- obsMapping = "$obsMapping && " + createCommand(
- "1.19.3-R0.1-SNAPSHOT",
- "com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_19_R2",
- file,
- shadowJar,
- targetJarFile,
- targetJarFile
- )
- obsMapping = "$obsMapping && " + createCommand(
- "1.19.4-R0.1-SNAPSHOT",
- "com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_19_R3",
- file,
- shadowJar,
- targetJarFile,
- targetJarFile
- )
- obsMapping = "$obsMapping && " + createCommand(
- "1.20.1-R0.1-SNAPSHOT",
- "com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_20_R1",
- file,
- shadowJar,
- targetJarFile,
- targetJarFile
- )
-
- if (System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("windows")) {
- commandLine = listOf("cmd", "/c", obsMapping.replace("\$HOME", "%userprofile%"))
- } else {
- commandLine = listOf("sh", "-c", obsMapping)
- }
+ from(zipTree(File("./build/libs/" + (tasks.getByName("shadowJar") as Jar).archiveName)))
+ archiveName = "${baseName}-${version}-relocate.${extension}"
+ relocate("org.bstats", "com.github.shynixn.blockball.lib.org.bstats")
+ relocate("com.github.shynixn.mcutils", "com.github.shynixn.blockball.lib.com.github.shynixn.mcutils")
}
-fun createCommand(
- version: String,
- include: String,
- file: File,
- shadowJar: ShadowJar,
- sourceJarFile: File,
- targetJarFile: File
-): String {
- val obfArchiveName = "${shadowJar.baseName}-${shadowJar.version}-obfuscated.${shadowJar.extension}"
- val obfJarFile = File(buildDir, "libs/$obfArchiveName")
-
- return "java -jar ${file.absolutePath} -i \"$sourceJarFile\" -o \"$obfJarFile\" -only \"$include\" -m \"\$HOME/.m2/repository/org/spigotmc/minecraft-server/${version}/minecraft-server-${version}-maps-mojang.txt\" --reverse" +
- "&& java -jar ${file.absolutePath} -i \"$obfJarFile\" -o \"$targetJarFile\" -only \"$include\" -m \"\$HOME/.m2/repository/org/spigotmc/minecraft-server/${version}/minecraft-server-${version}-maps-spigot.csrg\""
+/**
+ * Create latest plugin jar file.
+ */
+tasks.register("pluginJarLatest", ShadowJar::class.java) {
+ dependsOn("relocatePluginJar")
+ from(zipTree(File("./build/libs/" + (tasks.getByName("relocatePluginJar") as Jar).archiveName)))
+ archiveName = "${baseName}-${version}-latest.${extension}"
+ // destinationDir = File("C:\\temp\\plugins")
+
+ exclude("com/github/shynixn/mcutils/**")
+ exclude("org/**")
+ exclude("kotlin/**")
+ exclude("javax/**")
+ exclude("com/google/**")
+ exclude("plugin-legacy.yml")
}
+
repositories {
maven("https://repo.extendedclip.com/content/repositories/placeholderapi")
maven("https://repo.codemc.org/repository/maven-public")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
+ maven("https://shynixn.github.io/m2/repository/mcutils")
}
dependencies {
implementation(project(":blockball-api"))
implementation(project(":blockball-bukkit-api"))
implementation(project(":blockball-core"))
- implementation(project(":blockball-bukkit-plugin:bukkit-nms-117R1"))
- implementation(project(":blockball-bukkit-plugin:bukkit-nms-118R1"))
- implementation(project(":blockball-bukkit-plugin:bukkit-nms-118R2"))
- implementation(project(":blockball-bukkit-plugin:bukkit-nms-119R1"))
- implementation(project(":blockball-bukkit-plugin:bukkit-nms-119R2"))
- implementation(project(":blockball-bukkit-plugin:bukkit-nms-119R3"))
- implementation(project(":blockball-bukkit-plugin:bukkit-nms-120R1"))
+
+ implementation("com.github.shynixn.mcutils:common:1.0.23")
+ implementation("com.github.shynixn.mcutils:packet:1.0.47")
implementation("com.github.shynixn.org.bstats:bstats-bukkit:1.7")
implementation("org.slf4j:slf4j-jdk14:1.7.25")
diff --git a/blockball-bukkit-plugin/bukkit-nms-117R1/build.gradle.kts b/blockball-bukkit-plugin/bukkit-nms-117R1/build.gradle.kts
deleted file mode 100644
index 1f5c2d647..000000000
--- a/blockball-bukkit-plugin/bukkit-nms-117R1/build.gradle.kts
+++ /dev/null
@@ -1,7 +0,0 @@
-dependencies {
- implementation(project(":blockball-api"))
- implementation(project(":blockball-core"))
- compileOnly("com.google.inject:guice:5.0.1")
- compileOnly("org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT:remapped-mojang")
- testImplementation("org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT:remapped-mojang")
-}
diff --git a/blockball-bukkit-plugin/bukkit-nms-117R1/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_17_R1/InternalVersionPacket117R1ServiceImpl.kt b/blockball-bukkit-plugin/bukkit-nms-117R1/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_17_R1/InternalVersionPacket117R1ServiceImpl.kt
deleted file mode 100644
index 10b1f96a4..000000000
--- a/blockball-bukkit-plugin/bukkit-nms-117R1/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_17_R1/InternalVersionPacket117R1ServiceImpl.kt
+++ /dev/null
@@ -1,187 +0,0 @@
-package com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_17_R1
-
-import com.github.shynixn.blockball.api.business.enumeration.CompatibilityArmorSlotType
-import com.github.shynixn.blockball.api.business.proxy.PluginProxy
-import com.github.shynixn.blockball.api.business.service.InternalVersionPacketService
-import com.github.shynixn.blockball.api.business.service.LoggingService
-import com.github.shynixn.blockball.api.persistence.entity.EntityMetaData
-import com.github.shynixn.blockball.api.persistence.entity.Position
-import com.google.inject.Inject
-import com.mojang.datafixers.util.Pair
-import io.netty.buffer.ByteBuf
-import io.netty.buffer.Unpooled
-import net.minecraft.core.Registry
-import net.minecraft.network.FriendlyByteBuf
-import net.minecraft.network.protocol.game.ClientboundAddMobPacket
-import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket
-import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket
-import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket
-import net.minecraft.world.entity.EntityType
-import net.minecraft.world.entity.EquipmentSlot
-import net.minecraft.world.item.ItemStack
-import java.nio.charset.Charset
-import java.util.*
-
-class InternalVersionPacket117R1ServiceImpl @Inject constructor(
- private val pluginProxy: PluginProxy,
- private val loggingService: LoggingService
-) : InternalVersionPacketService {
- private val craftItemStackNmsMethod by lazy {
- pluginProxy.findClazz("org.bukkit.craftbukkit.VERSION.inventory.CraftItemStack")
- .getDeclaredMethod("asNMSCopy", pluginProxy.findClazz("org.bukkit.inventory.ItemStack"))
- }
- private val enumItemSlotClazz by lazy {
- try {
- pluginProxy.findClazz("net.minecraft.world.entity.EnumItemSlot")
- } catch (e: Exception) {
- pluginProxy.findClazz("net.minecraft.server.VERSION.EnumItemSlot")
- }
- }
- private val mojangPairClazz by lazy {
- pluginProxy.findClazz("com.mojang.datafixers.util.Pair")
- }
-
- /**
- * Creates a new teleport packet.
- */
- override fun createEntityTeleportPacket(entityId: Int, position: Position): Any {
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeBoolean(false)
- return ClientboundTeleportEntityPacket(buffer)
- }
-
- /**
- * Creates a spawn packet.
- */
- override fun createEntitySpawnPacket(entityId: Int, entityType: String, position: Position): Any {
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
-
- val entityUUID = UUID.randomUUID()
- buffer.writeLong(entityUUID.mostSignificantBits)
- buffer.writeLong(entityUUID.leastSignificantBits)
- val nmsEntityType = if (entityType == "ARMOR_STAND") {
- EntityType.ARMOR_STAND
- } else {
- EntityType.SLIME
- }
-
- val nmsEntityId = Registry.ENTITY_TYPE::class.java.getDeclaredMethod("getId", Any::class.java)
- .invoke(Registry.ENTITY_TYPE, nmsEntityType) as Int
-
- buffer.writeId(nmsEntityId)
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte(0)
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
-
- return ClientboundAddMobPacket(buffer)
- }
-
- /**
- * Creates a entity metadata packet.
- */
- override fun createEntityMetaDataPacket(entityId: Int, entityMetaData: EntityMetaData): Any {
- // https://wiki.vg/Entity_metadata#Entity_Metadata_Format -> Value of Type field. Type of Value = Boolean -> 7.
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
-
- val byteTypeValue = 0
- val intTypeValue = 1
- val booleanTypeValue = 7
- val optChatTypeValue = 5
- val rotationTypeValue = 8
-
- if (entityMetaData.customNameVisible != null) {
- buffer.writeByte(3)
- buffer.writeId(booleanTypeValue)
- buffer.writeBoolean(entityMetaData.customNameVisible!!)
- }
-
- if (entityMetaData.customname != null) {
- val payload = "{\"text\": \"${entityMetaData.customname}\"}".toByteArray(Charset.forName("UTF-8"))
- buffer.writeByte(2)
- buffer.writeId(optChatTypeValue)
- buffer.writeBoolean(true)
- buffer.writeId(payload.size)
- buffer.writeBytes(payload)
- }
-
- if (entityMetaData.slimeSize != null) {
- val slimeSizeIndex = 16
- buffer.writeByte(slimeSizeIndex)
- buffer.writeId(intTypeValue)
- buffer.writeId(entityMetaData.slimeSize!!)
- }
-
- if (entityMetaData.armorstandHeadRotation != null) {
- buffer.writeByte(16)
- buffer.writeId(rotationTypeValue)
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.x.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.y.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.z.toFloat())
- }
-
- if (entityMetaData.isInvisible != null) {
- buffer.writeByte(0)
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x20)
- }
-
- if (entityMetaData.isSmall != null && entityMetaData.isSmall!!) {
- buffer.writeByte(14)
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x01)
- }
-
- buffer.writeByte(255)
- return ClientboundSetEntityDataPacket(buffer)
- }
-
- /**
- * Creates an entity equipment packet.
- */
- override fun createEntityEquipmentPacket(entityId: Int, slot: CompatibilityArmorSlotType, itemStack: I): Any {
- val nmsItemStack = craftItemStackNmsMethod.invoke(null, itemStack)
- val pair = mojangPairClazz.getDeclaredConstructor(Any::class.java, Any::class.java)
- .newInstance(enumItemSlotClazz.enumConstants[slot.id116], nmsItemStack)
- return ClientboundSetEquipmentPacket(
- entityId,
- mutableListOf(pair) as MutableList>?
- )
- }
-
- /**
- * Mathhelper
- */
- private fun mathhelperA(var0: Double, var2: Double, var4: Double): Double {
- return if (var0 < var2) {
- var2
- } else {
- if (var0 > var4) var4 else var0
- }
- }
-
- /**
- * Writes id.
- */
- private fun ByteBuf.writeId(id: Int) {
- var i = id
- while (i and -128 != 0) {
- writeByte(i and 127 or 128)
- i = i ushr 7
- }
- writeByte(i)
- }
-}
diff --git a/blockball-bukkit-plugin/bukkit-nms-118R1/build.gradle.kts b/blockball-bukkit-plugin/bukkit-nms-118R1/build.gradle.kts
deleted file mode 100644
index e0a012b30..000000000
--- a/blockball-bukkit-plugin/bukkit-nms-118R1/build.gradle.kts
+++ /dev/null
@@ -1,24 +0,0 @@
-repositories {
- maven(url = "https://libraries.minecraft.net")
-}
-
-dependencies {
- // Dependencies of spigot mojang want to restrict usage to only Java 16. However, we do not care
- // what they want because the general compatibility of this plugin is Java 8. The plugin
- // guarantees that everything works during runtime. This error is a false positive.
- components {
- all {
- allVariants {
- attributes {
- attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
- }
- }
- }
- }
-
- implementation(project(":blockball-api"))
- implementation(project(":blockball-core"))
- compileOnly("com.google.inject:guice:5.0.1")
- compileOnly("org.spigotmc:spigot:1.18-R0.1-SNAPSHOT:remapped-mojang")
- testImplementation("org.spigotmc:spigot:1.18-R0.1-SNAPSHOT:remapped-mojang")
-}
diff --git a/blockball-bukkit-plugin/bukkit-nms-118R1/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_18_R1/InternalVersionPacket118R1ServiceImpl.kt b/blockball-bukkit-plugin/bukkit-nms-118R1/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_18_R1/InternalVersionPacket118R1ServiceImpl.kt
deleted file mode 100644
index 2f3509a33..000000000
--- a/blockball-bukkit-plugin/bukkit-nms-118R1/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_18_R1/InternalVersionPacket118R1ServiceImpl.kt
+++ /dev/null
@@ -1,186 +0,0 @@
-package com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_18_R1
-
-import com.github.shynixn.blockball.api.business.enumeration.CompatibilityArmorSlotType
-import com.github.shynixn.blockball.api.business.proxy.PluginProxy
-import com.github.shynixn.blockball.api.business.service.InternalVersionPacketService
-import com.github.shynixn.blockball.api.business.service.LoggingService
-import com.github.shynixn.blockball.api.persistence.entity.EntityMetaData
-import com.github.shynixn.blockball.api.persistence.entity.Position
-import com.google.inject.Inject
-import com.mojang.datafixers.util.Pair
-import io.netty.buffer.ByteBuf
-import io.netty.buffer.Unpooled
-import net.minecraft.core.Registry
-import net.minecraft.network.FriendlyByteBuf
-import net.minecraft.network.protocol.game.ClientboundAddMobPacket
-import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket
-import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket
-import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket
-import net.minecraft.world.entity.EntityType
-import net.minecraft.world.entity.EquipmentSlot
-import net.minecraft.world.item.ItemStack
-import java.nio.charset.Charset
-import java.util.*
-
-class InternalVersionPacket118R1ServiceImpl @Inject constructor(
- private val pluginProxy: PluginProxy,
- private val loggingService: LoggingService
-) : InternalVersionPacketService {
- private val craftItemStackNmsMethod by lazy {
- pluginProxy.findClazz("org.bukkit.craftbukkit.VERSION.inventory.CraftItemStack")
- .getDeclaredMethod("asNMSCopy", pluginProxy.findClazz("org.bukkit.inventory.ItemStack"))
- }
- private val enumItemSlotClazz by lazy {
- try {
- pluginProxy.findClazz("net.minecraft.world.entity.EnumItemSlot")
- } catch (e: Exception) {
- pluginProxy.findClazz("net.minecraft.server.VERSION.EnumItemSlot")
- }
- }
- private val mojangPairClazz by lazy {
- pluginProxy.findClazz("com.mojang.datafixers.util.Pair")
- }
-
- /**
- * Creates a new teleport packet.
- */
- override fun createEntityTeleportPacket(entityId: Int, position: Position): Any {
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeBoolean(false)
- return ClientboundTeleportEntityPacket(buffer)
- }
-
- /**
- * Creates a spawn packet.
- */
- override fun createEntitySpawnPacket(entityId: Int, entityType: String, position: Position): Any {
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
-
- val entityUUID = UUID.randomUUID()
- buffer.writeLong(entityUUID.mostSignificantBits)
- buffer.writeLong(entityUUID.leastSignificantBits)
- val nmsEntityType = if (entityType == "ARMOR_STAND") {
- EntityType.ARMOR_STAND
- } else {
- EntityType.SLIME
- }
-
- val nmsEntityId = Registry.ENTITY_TYPE.getId(nmsEntityType)
-
- buffer.writeId(nmsEntityId)
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte(0)
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
-
- return ClientboundAddMobPacket(buffer)
- }
-
- /**
- * Creates a entity metadata packet.
- */
- override fun createEntityMetaDataPacket(entityId: Int, entityMetaData: EntityMetaData): Any {
- // https://wiki.vg/Entity_metadata#Entity_Metadata_Format -> Value of Type field. Type of Value = Boolean -> 7.
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
-
- val byteTypeValue = 0
- val intTypeValue = 1
- val booleanTypeValue = 7
- val optChatTypeValue = 5
- val rotationTypeValue = 8
-
- if (entityMetaData.customNameVisible != null) {
- buffer.writeByte(3)
- buffer.writeId(booleanTypeValue)
- buffer.writeBoolean(entityMetaData.customNameVisible!!)
- }
-
- if (entityMetaData.customname != null) {
- val payload = "{\"text\": \"${entityMetaData.customname}\"}".toByteArray(Charset.forName("UTF-8"))
- buffer.writeByte(2)
- buffer.writeId(optChatTypeValue)
- buffer.writeBoolean(true)
- buffer.writeId(payload.size)
- buffer.writeBytes(payload)
- }
-
- if (entityMetaData.slimeSize != null) {
- val slimeSizeIndex = 16
- buffer.writeByte(slimeSizeIndex)
- buffer.writeId(intTypeValue)
- buffer.writeId(entityMetaData.slimeSize!!)
- }
-
- if (entityMetaData.armorstandHeadRotation != null) {
- buffer.writeByte(16)
- buffer.writeId(rotationTypeValue)
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.x.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.y.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.z.toFloat())
- }
-
- if (entityMetaData.isInvisible != null) {
- buffer.writeByte(0)
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x20)
- }
-
- if (entityMetaData.isSmall != null && entityMetaData.isSmall!!) {
- buffer.writeByte(15)
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x01)
- }
-
- buffer.writeByte(255)
- return ClientboundSetEntityDataPacket(buffer)
- }
-
- /**
- * Creates an entity equipment packet.
- */
- override fun createEntityEquipmentPacket(entityId: Int, slot: CompatibilityArmorSlotType, itemStack: I): Any {
- val nmsItemStack = craftItemStackNmsMethod.invoke(null, itemStack)
- val pair = mojangPairClazz.getDeclaredConstructor(Any::class.java, Any::class.java)
- .newInstance(enumItemSlotClazz.enumConstants[slot.id116], nmsItemStack)
- return ClientboundSetEquipmentPacket(
- entityId,
- mutableListOf(pair) as MutableList>?
- )
- }
-
- /**
- * Mathhelper
- */
- private fun mathhelperA(var0: Double, var2: Double, var4: Double): Double {
- return if (var0 < var2) {
- var2
- } else {
- if (var0 > var4) var4 else var0
- }
- }
-
- /**
- * Writes id.
- */
- private fun ByteBuf.writeId(id: Int) {
- var i = id
- while (i and -128 != 0) {
- writeByte(i and 127 or 128)
- i = i ushr 7
- }
- writeByte(i)
- }
-}
diff --git a/blockball-bukkit-plugin/bukkit-nms-118R2/build.gradle.kts b/blockball-bukkit-plugin/bukkit-nms-118R2/build.gradle.kts
deleted file mode 100644
index 6863b461a..000000000
--- a/blockball-bukkit-plugin/bukkit-nms-118R2/build.gradle.kts
+++ /dev/null
@@ -1,24 +0,0 @@
-repositories {
- maven(url = "https://libraries.minecraft.net")
-}
-
-dependencies {
- // Dependencies of spigot mojang want to restrict usage to only Java 17. However, we do not care
- // what they want because the general compatibility of this plugin is Java 8. The plugin
- // guarantees that everything works during runtime. This error is a false positive.
- components {
- all {
- allVariants {
- attributes {
- attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
- }
- }
- }
- }
-
- implementation(project(":blockball-api"))
- implementation(project(":blockball-core"))
- compileOnly("com.google.inject:guice:5.0.1")
- compileOnly("org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:remapped-mojang")
- testImplementation("org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:remapped-mojang")
-}
diff --git a/blockball-bukkit-plugin/bukkit-nms-118R2/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_18_R2/InternalVersionPacket118R2ServiceImpl.kt b/blockball-bukkit-plugin/bukkit-nms-118R2/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_18_R2/InternalVersionPacket118R2ServiceImpl.kt
deleted file mode 100644
index 756c4d92e..000000000
--- a/blockball-bukkit-plugin/bukkit-nms-118R2/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_18_R2/InternalVersionPacket118R2ServiceImpl.kt
+++ /dev/null
@@ -1,185 +0,0 @@
-package com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_18_R2
-
-import com.github.shynixn.blockball.api.business.enumeration.CompatibilityArmorSlotType
-import com.github.shynixn.blockball.api.business.proxy.PluginProxy
-import com.github.shynixn.blockball.api.business.service.InternalVersionPacketService
-import com.github.shynixn.blockball.api.business.service.LoggingService
-import com.github.shynixn.blockball.api.persistence.entity.EntityMetaData
-import com.github.shynixn.blockball.api.persistence.entity.Position
-import com.google.inject.Inject
-import com.mojang.datafixers.util.Pair
-import io.netty.buffer.ByteBuf
-import io.netty.buffer.Unpooled
-import net.minecraft.core.Registry
-import net.minecraft.network.FriendlyByteBuf
-import net.minecraft.network.protocol.game.ClientboundAddMobPacket
-import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket
-import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket
-import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket
-import net.minecraft.world.entity.EntityType
-import net.minecraft.world.entity.EquipmentSlot
-import net.minecraft.world.item.ItemStack
-import java.nio.charset.Charset
-import java.util.*
-
-class InternalVersionPacket118R2ServiceImpl @Inject constructor(
- private val pluginProxy: PluginProxy
-) : InternalVersionPacketService {
- private val craftItemStackNmsMethod by lazy {
- pluginProxy.findClazz("org.bukkit.craftbukkit.VERSION.inventory.CraftItemStack")
- .getDeclaredMethod("asNMSCopy", pluginProxy.findClazz("org.bukkit.inventory.ItemStack"))
- }
- private val enumItemSlotClazz by lazy {
- try {
- pluginProxy.findClazz("net.minecraft.world.entity.EnumItemSlot")
- } catch (e: Exception) {
- pluginProxy.findClazz("net.minecraft.server.VERSION.EnumItemSlot")
- }
- }
- private val mojangPairClazz by lazy {
- pluginProxy.findClazz("com.mojang.datafixers.util.Pair")
- }
-
- /**
- * Creates a new teleport packet.
- */
- override fun createEntityTeleportPacket(entityId: Int, position: Position): Any {
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeBoolean(false)
- return ClientboundTeleportEntityPacket(buffer)
- }
-
- /**
- * Creates a spawn packet.
- */
- override fun createEntitySpawnPacket(entityId: Int, entityType: String, position: Position): Any {
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
-
- val entityUUID = UUID.randomUUID()
- buffer.writeLong(entityUUID.mostSignificantBits)
- buffer.writeLong(entityUUID.leastSignificantBits)
- val nmsEntityType = if (entityType == "ARMOR_STAND") {
- EntityType.ARMOR_STAND
- } else {
- EntityType.SLIME
- }
-
- val nmsEntityId = Registry.ENTITY_TYPE.getId(nmsEntityType)
-
- buffer.writeId(nmsEntityId)
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte(0)
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
-
- return ClientboundAddMobPacket(buffer)
- }
-
- /**
- * Creates a entity metadata packet.
- */
- override fun createEntityMetaDataPacket(entityId: Int, entityMetaData: EntityMetaData): Any {
- // https://wiki.vg/Entity_metadata#Entity_Metadata_Format -> Value of Type field. Type of Value = Boolean -> 7.
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
-
- val byteTypeValue = 0
- val intTypeValue = 1
- val booleanTypeValue = 7
- val optChatTypeValue = 5
- val rotationTypeValue = 8
-
- if (entityMetaData.customNameVisible != null) {
- buffer.writeByte(3)
- buffer.writeId(booleanTypeValue)
- buffer.writeBoolean(entityMetaData.customNameVisible!!)
- }
-
- if (entityMetaData.customname != null) {
- val payload = "{\"text\": \"${entityMetaData.customname}\"}".toByteArray(Charset.forName("UTF-8"))
- buffer.writeByte(2)
- buffer.writeId(optChatTypeValue)
- buffer.writeBoolean(true)
- buffer.writeId(payload.size)
- buffer.writeBytes(payload)
- }
-
- if (entityMetaData.slimeSize != null) {
- val slimeSizeIndex = 16
- buffer.writeByte(slimeSizeIndex)
- buffer.writeId(intTypeValue)
- buffer.writeId(entityMetaData.slimeSize!!)
- }
-
- if (entityMetaData.armorstandHeadRotation != null) {
- buffer.writeByte(16)
- buffer.writeId(rotationTypeValue)
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.x.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.y.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.z.toFloat())
- }
-
- if (entityMetaData.isInvisible != null) {
- buffer.writeByte(0)
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x20)
- }
-
- if (entityMetaData.isSmall != null && entityMetaData.isSmall!!) {
- buffer.writeByte(15)
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x01)
- }
-
- buffer.writeByte(255)
- return ClientboundSetEntityDataPacket(buffer)
- }
-
- /**
- * Creates an entity equipment packet.
- */
- override fun createEntityEquipmentPacket(entityId: Int, slot: CompatibilityArmorSlotType, itemStack: I): Any {
- val nmsItemStack = craftItemStackNmsMethod.invoke(null, itemStack)
- val pair = mojangPairClazz.getDeclaredConstructor(Any::class.java, Any::class.java)
- .newInstance(enumItemSlotClazz.enumConstants[slot.id116], nmsItemStack)
- return ClientboundSetEquipmentPacket(
- entityId,
- mutableListOf(pair) as MutableList>?
- )
- }
-
- /**
- * Mathhelper
- */
- private fun mathhelperA(var0: Double, var2: Double, var4: Double): Double {
- return if (var0 < var2) {
- var2
- } else {
- if (var0 > var4) var4 else var0
- }
- }
-
- /**
- * Writes id.
- */
- private fun ByteBuf.writeId(id: Int) {
- var i = id
- while (i and -128 != 0) {
- writeByte(i and 127 or 128)
- i = i ushr 7
- }
- writeByte(i)
- }
-}
diff --git a/blockball-bukkit-plugin/bukkit-nms-119R1/build.gradle.kts b/blockball-bukkit-plugin/bukkit-nms-119R1/build.gradle.kts
deleted file mode 100644
index 0d5869c67..000000000
--- a/blockball-bukkit-plugin/bukkit-nms-119R1/build.gradle.kts
+++ /dev/null
@@ -1,24 +0,0 @@
-repositories {
- maven(url = "https://libraries.minecraft.net")
-}
-
-dependencies {
- // Dependencies of spigot mojang want to restrict usage to only Java 17. However, we do not care
- // what they want because the general compatibility of this plugin is Java 8. The plugin
- // guarantees that everything works during runtime. This error is a false positive.
- components {
- all {
- allVariants {
- attributes {
- attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
- }
- }
- }
- }
-
- implementation(project(":blockball-api"))
- implementation(project(":blockball-core"))
- compileOnly("com.google.inject:guice:5.0.1")
- compileOnly("org.spigotmc:spigot:1.19-R0.1-SNAPSHOT:remapped-mojang")
- testImplementation("org.spigotmc:spigot:1.19-R0.1-SNAPSHOT:remapped-mojang")
-}
diff --git a/blockball-bukkit-plugin/bukkit-nms-119R1/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_19_R1/InternalVersionPacket119R1ServiceImpl.kt b/blockball-bukkit-plugin/bukkit-nms-119R1/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_19_R1/InternalVersionPacket119R1ServiceImpl.kt
deleted file mode 100644
index b310ad6cc..000000000
--- a/blockball-bukkit-plugin/bukkit-nms-119R1/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_19_R1/InternalVersionPacket119R1ServiceImpl.kt
+++ /dev/null
@@ -1,185 +0,0 @@
-package com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_19_R1
-
-import com.github.shynixn.blockball.api.business.enumeration.CompatibilityArmorSlotType
-import com.github.shynixn.blockball.api.business.proxy.PluginProxy
-import com.github.shynixn.blockball.api.business.service.InternalVersionPacketService
-import com.github.shynixn.blockball.api.persistence.entity.EntityMetaData
-import com.github.shynixn.blockball.api.persistence.entity.Position
-import com.google.inject.Inject
-import com.mojang.datafixers.util.Pair
-import io.netty.buffer.ByteBuf
-import io.netty.buffer.Unpooled
-import net.minecraft.core.Registry
-import net.minecraft.network.FriendlyByteBuf
-import net.minecraft.network.protocol.game.ClientboundAddEntityPacket
-import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket
-import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket
-import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket
-import net.minecraft.world.entity.EntityType
-import net.minecraft.world.entity.EquipmentSlot
-import net.minecraft.world.item.ItemStack
-import java.nio.charset.Charset
-import java.util.*
-
-class InternalVersionPacket119R1ServiceImpl @Inject constructor(
- private val pluginProxy: PluginProxy
-) : InternalVersionPacketService {
- private val craftItemStackNmsMethod by lazy {
- pluginProxy.findClazz("org.bukkit.craftbukkit.VERSION.inventory.CraftItemStack")
- .getDeclaredMethod("asNMSCopy", pluginProxy.findClazz("org.bukkit.inventory.ItemStack"))
- }
- private val enumItemSlotClazz by lazy {
- try {
- pluginProxy.findClazz("net.minecraft.world.entity.EnumItemSlot")
- } catch (e: Exception) {
- pluginProxy.findClazz("net.minecraft.server.VERSION.EnumItemSlot")
- }
- }
- private val mojangPairClazz by lazy {
- pluginProxy.findClazz("com.mojang.datafixers.util.Pair")
- }
-
- /**
- * Creates a new teleport packet.
- */
- override fun createEntityTeleportPacket(entityId: Int, position: Position): Any {
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeBoolean(false)
- return ClientboundTeleportEntityPacket(buffer)
- }
-
- /**
- * Creates a spawn packet.
- */
- override fun createEntitySpawnPacket(entityId: Int, entityType: String, position: Position): Any {
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
-
- val entityUUID = UUID.randomUUID()
- buffer.writeLong(entityUUID.mostSignificantBits)
- buffer.writeLong(entityUUID.leastSignificantBits)
- val nmsEntityType = if (entityType == "ARMOR_STAND") {
- EntityType.ARMOR_STAND
- } else {
- EntityType.SLIME
- }
-
- val nmsEntityId = Registry.ENTITY_TYPE.getId(nmsEntityType)
-
- buffer.writeId(nmsEntityId)
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte(0)
- buffer.writeId(0)
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
-
- return ClientboundAddEntityPacket(buffer)
- }
-
- /**
- * Creates a entity metadata packet.
- */
- override fun createEntityMetaDataPacket(entityId: Int, entityMetaData: EntityMetaData): Any {
- // https://wiki.vg/Entity_metadata#Entity_Metadata_Format -> Value of Type field. Type of Value = Boolean -> 7.
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
-
- val byteTypeValue = 0
- val intTypeValue = 1
- val booleanTypeValue = 7
- val optChatTypeValue = 5
- val rotationTypeValue = 8
-
- if (entityMetaData.customNameVisible != null) {
- buffer.writeByte(3)
- buffer.writeId(booleanTypeValue)
- buffer.writeBoolean(entityMetaData.customNameVisible!!)
- }
-
- if (entityMetaData.customname != null) {
- val payload = "{\"text\": \"${entityMetaData.customname}\"}".toByteArray(Charset.forName("UTF-8"))
- buffer.writeByte(2)
- buffer.writeId(optChatTypeValue)
- buffer.writeBoolean(true)
- buffer.writeId(payload.size)
- buffer.writeBytes(payload)
- }
-
- if (entityMetaData.slimeSize != null) {
- val slimeSizeIndex = 16
- buffer.writeByte(slimeSizeIndex)
- buffer.writeId(intTypeValue)
- buffer.writeId(entityMetaData.slimeSize!!)
- }
-
- if (entityMetaData.armorstandHeadRotation != null) {
- buffer.writeByte(16)
- buffer.writeId(rotationTypeValue)
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.x.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.y.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.z.toFloat())
- }
-
- if (entityMetaData.isInvisible != null) {
- buffer.writeByte(0)
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x20)
- }
-
- if (entityMetaData.isSmall != null && entityMetaData.isSmall!!) {
- buffer.writeByte(15)
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x01)
- }
-
- buffer.writeByte(255)
- return ClientboundSetEntityDataPacket(buffer)
- }
-
- /**
- * Creates an entity equipment packet.
- */
- override fun createEntityEquipmentPacket(entityId: Int, slot: CompatibilityArmorSlotType, itemStack: I): Any {
- val nmsItemStack = craftItemStackNmsMethod.invoke(null, itemStack)
- val pair = mojangPairClazz.getDeclaredConstructor(Any::class.java, Any::class.java)
- .newInstance(enumItemSlotClazz.enumConstants[slot.id116], nmsItemStack)
- return ClientboundSetEquipmentPacket(
- entityId,
- mutableListOf(pair) as MutableList>?
- )
- }
-
- /**
- * Mathhelper
- */
- private fun mathhelperA(var0: Double, var2: Double, var4: Double): Double {
- return if (var0 < var2) {
- var2
- } else {
- if (var0 > var4) var4 else var0
- }
- }
-
- /**
- * Writes id.
- */
- private fun ByteBuf.writeId(id: Int) {
- var i = id
- while (i and -128 != 0) {
- writeByte(i and 127 or 128)
- i = i ushr 7
- }
- writeByte(i)
- }
-}
diff --git a/blockball-bukkit-plugin/bukkit-nms-119R2/build.gradle.kts b/blockball-bukkit-plugin/bukkit-nms-119R2/build.gradle.kts
deleted file mode 100644
index c28727fdb..000000000
--- a/blockball-bukkit-plugin/bukkit-nms-119R2/build.gradle.kts
+++ /dev/null
@@ -1,24 +0,0 @@
-repositories {
- maven(url = "https://libraries.minecraft.net")
-}
-
-dependencies {
- // Dependencies of spigot mojang want to restrict usage to only Java 17. However, we do not care
- // what they want because the general compatibility of this plugin is Java 8. The plugin
- // guarantees that everything works during runtime. This error is a false positive.
- components {
- all {
- allVariants {
- attributes {
- attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
- }
- }
- }
- }
-
- implementation(project(":blockball-api"))
- implementation(project(":blockball-core"))
- compileOnly("com.google.inject:guice:5.0.1")
- compileOnly("org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:remapped-mojang")
- testImplementation("org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:remapped-mojang")
-}
diff --git a/blockball-bukkit-plugin/bukkit-nms-119R2/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_19_R2/InternalVersionPacket119R2ServiceImpl.kt b/blockball-bukkit-plugin/bukkit-nms-119R2/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_19_R2/InternalVersionPacket119R2ServiceImpl.kt
deleted file mode 100644
index a3a5b1151..000000000
--- a/blockball-bukkit-plugin/bukkit-nms-119R2/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_19_R2/InternalVersionPacket119R2ServiceImpl.kt
+++ /dev/null
@@ -1,187 +0,0 @@
-package com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_19_R2
-
-import com.github.shynixn.blockball.api.business.enumeration.CompatibilityArmorSlotType
-import com.github.shynixn.blockball.api.business.proxy.PluginProxy
-import com.github.shynixn.blockball.api.business.service.InternalVersionPacketService
-import com.github.shynixn.blockball.api.persistence.entity.EntityMetaData
-import com.github.shynixn.blockball.api.persistence.entity.Position
-import com.google.inject.Inject
-import com.mojang.datafixers.util.Pair
-import io.netty.buffer.ByteBuf
-import io.netty.buffer.Unpooled
-import net.minecraft.core.Registry
-import net.minecraft.core.registries.BuiltInRegistries
-import net.minecraft.network.FriendlyByteBuf
-import net.minecraft.network.protocol.game.ClientboundAddEntityPacket
-import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket
-import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket
-import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket
-import net.minecraft.world.entity.EntityType
-import net.minecraft.world.entity.EquipmentSlot
-import net.minecraft.world.item.ItemStack
-import java.nio.charset.Charset
-import java.util.*
-
-class InternalVersionPacket119R2ServiceImpl @Inject constructor(
- private val pluginProxy: PluginProxy
-) : InternalVersionPacketService {
- private val craftItemStackNmsMethod by lazy {
- pluginProxy.findClazz("org.bukkit.craftbukkit.VERSION.inventory.CraftItemStack")
- .getDeclaredMethod("asNMSCopy", pluginProxy.findClazz("org.bukkit.inventory.ItemStack"))
- }
- private val enumItemSlotClazz by lazy {
- try {
- pluginProxy.findClazz("net.minecraft.world.entity.EnumItemSlot")
- } catch (e: Exception) {
- pluginProxy.findClazz("net.minecraft.server.VERSION.EnumItemSlot")
- }
- }
- private val mojangPairClazz by lazy {
- pluginProxy.findClazz("com.mojang.datafixers.util.Pair")
- }
-
- /**
- * Creates a new teleport packet.
- */
- override fun createEntityTeleportPacket(entityId: Int, position: Position): Any {
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeBoolean(false)
- return ClientboundTeleportEntityPacket(buffer)
- }
-
- /**
- * Creates a spawn packet.
- */
- override fun createEntitySpawnPacket(entityId: Int, entityType: String, position: Position): Any {
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
-
- val entityUUID = UUID.randomUUID()
- buffer.writeLong(entityUUID.mostSignificantBits)
- buffer.writeLong(entityUUID.leastSignificantBits)
- val nmsEntityType = if (entityType == "ARMOR_STAND") {
- EntityType.ARMOR_STAND
- } else {
- EntityType.SLIME
- }
-
- val registry : Registry> = BuiltInRegistries.ENTITY_TYPE
- val nmsEntityId = registry.getId(nmsEntityType)
-
- buffer.writeId(nmsEntityId)
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte(0)
- buffer.writeId(0)
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
-
- return ClientboundAddEntityPacket(buffer)
- }
-
- /**
- * Creates a entity metadata packet.
- */
- override fun createEntityMetaDataPacket(entityId: Int, entityMetaData: EntityMetaData): Any {
- // https://wiki.vg/Entity_metadata#Entity_Metadata_Format -> Value of Type field. Type of Value = Boolean -> 7.
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
-
- val byteTypeValue = 0
- val intTypeValue = 1
- val booleanTypeValue = 8
- val optChatTypeValue = 6
- val rotationTypeValue = 9
-
- if (entityMetaData.customNameVisible != null) {
- buffer.writeByte(3)
- buffer.writeId(booleanTypeValue)
- buffer.writeBoolean(entityMetaData.customNameVisible!!)
- }
-
- if (entityMetaData.customname != null) {
- val payload = "{\"text\": \"${entityMetaData.customname}\"}".toByteArray(Charset.forName("UTF-8"))
- buffer.writeByte(2)
- buffer.writeId(optChatTypeValue)
- buffer.writeBoolean(true)
- buffer.writeId(payload.size)
- buffer.writeBytes(payload)
- }
-
- if (entityMetaData.slimeSize != null) {
- val slimeSizeIndex = 16
- buffer.writeByte(slimeSizeIndex)
- buffer.writeId(intTypeValue)
- buffer.writeId(entityMetaData.slimeSize!!)
- }
-
- if (entityMetaData.armorstandHeadRotation != null) {
- buffer.writeByte(16)
- buffer.writeId(rotationTypeValue)
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.x.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.y.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.z.toFloat())
- }
-
- if (entityMetaData.isInvisible != null) {
- buffer.writeByte(0)
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x20)
- }
-
- if (entityMetaData.isSmall != null && entityMetaData.isSmall!!) {
- buffer.writeByte(15)
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x01)
- }
-
- buffer.writeByte(255)
- return ClientboundSetEntityDataPacket(buffer)
- }
-
- /**
- * Creates an entity equipment packet.
- */
- override fun createEntityEquipmentPacket(entityId: Int, slot: CompatibilityArmorSlotType, itemStack: I): Any {
- val nmsItemStack = craftItemStackNmsMethod.invoke(null, itemStack)
- val pair = mojangPairClazz.getDeclaredConstructor(Any::class.java, Any::class.java)
- .newInstance(enumItemSlotClazz.enumConstants[slot.id116], nmsItemStack)
- return ClientboundSetEquipmentPacket(
- entityId,
- mutableListOf(pair) as MutableList>?
- )
- }
-
- /**
- * Mathhelper
- */
- private fun mathhelperA(var0: Double, var2: Double, var4: Double): Double {
- return if (var0 < var2) {
- var2
- } else {
- if (var0 > var4) var4 else var0
- }
- }
-
- /**
- * Writes id.
- */
- private fun ByteBuf.writeId(id: Int) {
- var i = id
- while (i and -128 != 0) {
- writeByte(i and 127 or 128)
- i = i ushr 7
- }
- writeByte(i)
- }
-}
diff --git a/blockball-bukkit-plugin/bukkit-nms-119R3/build.gradle.kts b/blockball-bukkit-plugin/bukkit-nms-119R3/build.gradle.kts
deleted file mode 100644
index 2448cbf73..000000000
--- a/blockball-bukkit-plugin/bukkit-nms-119R3/build.gradle.kts
+++ /dev/null
@@ -1,24 +0,0 @@
-repositories {
- maven(url = "https://libraries.minecraft.net")
-}
-
-dependencies {
- // Dependencies of spigot mojang want to restrict usage to only Java 17. However, we do not care
- // what they want because the general compatibility of this plugin is Java 8. The plugin
- // guarantees that everything works during runtime. This error is a false positive.
- components {
- all {
- allVariants {
- attributes {
- attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
- }
- }
- }
- }
-
- implementation(project(":blockball-api"))
- implementation(project(":blockball-core"))
- compileOnly("com.google.inject:guice:5.0.1")
- compileOnly("org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT:remapped-mojang")
- testImplementation("org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT:remapped-mojang")
-}
diff --git a/blockball-bukkit-plugin/bukkit-nms-119R3/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_19_R3/InternalVersionPacket119R3ServiceImpl.kt b/blockball-bukkit-plugin/bukkit-nms-119R3/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_19_R3/InternalVersionPacket119R3ServiceImpl.kt
deleted file mode 100644
index c2dfc079d..000000000
--- a/blockball-bukkit-plugin/bukkit-nms-119R3/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_19_R3/InternalVersionPacket119R3ServiceImpl.kt
+++ /dev/null
@@ -1,187 +0,0 @@
-package com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_19_R3
-
-import com.github.shynixn.blockball.api.business.enumeration.CompatibilityArmorSlotType
-import com.github.shynixn.blockball.api.business.proxy.PluginProxy
-import com.github.shynixn.blockball.api.business.service.InternalVersionPacketService
-import com.github.shynixn.blockball.api.persistence.entity.EntityMetaData
-import com.github.shynixn.blockball.api.persistence.entity.Position
-import com.google.inject.Inject
-import com.mojang.datafixers.util.Pair
-import io.netty.buffer.ByteBuf
-import io.netty.buffer.Unpooled
-import net.minecraft.core.Registry
-import net.minecraft.core.registries.BuiltInRegistries
-import net.minecraft.network.FriendlyByteBuf
-import net.minecraft.network.protocol.game.ClientboundAddEntityPacket
-import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket
-import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket
-import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket
-import net.minecraft.world.entity.EntityType
-import net.minecraft.world.entity.EquipmentSlot
-import net.minecraft.world.item.ItemStack
-import java.nio.charset.Charset
-import java.util.*
-
-class InternalVersionPacket119R3ServiceImpl @Inject constructor(
- private val pluginProxy: PluginProxy
-) : InternalVersionPacketService {
- private val craftItemStackNmsMethod by lazy {
- pluginProxy.findClazz("org.bukkit.craftbukkit.VERSION.inventory.CraftItemStack")
- .getDeclaredMethod("asNMSCopy", pluginProxy.findClazz("org.bukkit.inventory.ItemStack"))
- }
- private val enumItemSlotClazz by lazy {
- try {
- pluginProxy.findClazz("net.minecraft.world.entity.EnumItemSlot")
- } catch (e: Exception) {
- pluginProxy.findClazz("net.minecraft.server.VERSION.EnumItemSlot")
- }
- }
- private val mojangPairClazz by lazy {
- pluginProxy.findClazz("com.mojang.datafixers.util.Pair")
- }
-
- /**
- * Creates a new teleport packet.
- */
- override fun createEntityTeleportPacket(entityId: Int, position: Position): Any {
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeBoolean(false)
- return ClientboundTeleportEntityPacket(buffer)
- }
-
- /**
- * Creates a spawn packet.
- */
- override fun createEntitySpawnPacket(entityId: Int, entityType: String, position: Position): Any {
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
-
- val entityUUID = UUID.randomUUID()
- buffer.writeLong(entityUUID.mostSignificantBits)
- buffer.writeLong(entityUUID.leastSignificantBits)
- val nmsEntityType = if (entityType == "ARMOR_STAND") {
- EntityType.ARMOR_STAND
- } else {
- EntityType.SLIME
- }
-
- val registry : Registry> = BuiltInRegistries.ENTITY_TYPE
- val nmsEntityId = registry.getId(nmsEntityType)
-
- buffer.writeId(nmsEntityId)
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte(0)
- buffer.writeId(0)
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
-
- return ClientboundAddEntityPacket(buffer)
- }
-
- /**
- * Creates a entity metadata packet.
- */
- override fun createEntityMetaDataPacket(entityId: Int, entityMetaData: EntityMetaData): Any {
- // https://wiki.vg/Entity_metadata#Entity_Metadata_Format -> Value of Type field. Type of Value = Boolean -> 7.
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
-
- val byteTypeValue = 0
- val intTypeValue = 1
- val booleanTypeValue = 8
- val optChatTypeValue = 6
- val rotationTypeValue = 9
-
- if (entityMetaData.customNameVisible != null) {
- buffer.writeByte(3)
- buffer.writeId(booleanTypeValue)
- buffer.writeBoolean(entityMetaData.customNameVisible!!)
- }
-
- if (entityMetaData.customname != null) {
- val payload = "{\"text\": \"${entityMetaData.customname}\"}".toByteArray(Charset.forName("UTF-8"))
- buffer.writeByte(2)
- buffer.writeId(optChatTypeValue)
- buffer.writeBoolean(true)
- buffer.writeId(payload.size)
- buffer.writeBytes(payload)
- }
-
- if (entityMetaData.slimeSize != null) {
- val slimeSizeIndex = 16
- buffer.writeByte(slimeSizeIndex)
- buffer.writeId(intTypeValue)
- buffer.writeId(entityMetaData.slimeSize!!)
- }
-
- if (entityMetaData.armorstandHeadRotation != null) {
- buffer.writeByte(16)
- buffer.writeId(rotationTypeValue)
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.x.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.y.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.z.toFloat())
- }
-
- if (entityMetaData.isInvisible != null) {
- buffer.writeByte(0)
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x20)
- }
-
- if (entityMetaData.isSmall != null && entityMetaData.isSmall!!) {
- buffer.writeByte(15)
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x01)
- }
-
- buffer.writeByte(255)
- return ClientboundSetEntityDataPacket(buffer)
- }
-
- /**
- * Creates an entity equipment packet.
- */
- override fun createEntityEquipmentPacket(entityId: Int, slot: CompatibilityArmorSlotType, itemStack: I): Any {
- val nmsItemStack = craftItemStackNmsMethod.invoke(null, itemStack)
- val pair = mojangPairClazz.getDeclaredConstructor(Any::class.java, Any::class.java)
- .newInstance(enumItemSlotClazz.enumConstants[slot.id116], nmsItemStack)
- return ClientboundSetEquipmentPacket(
- entityId,
- mutableListOf(pair) as MutableList>?
- )
- }
-
- /**
- * Mathhelper
- */
- private fun mathhelperA(var0: Double, var2: Double, var4: Double): Double {
- return if (var0 < var2) {
- var2
- } else {
- if (var0 > var4) var4 else var0
- }
- }
-
- /**
- * Writes id.
- */
- private fun ByteBuf.writeId(id: Int) {
- var i = id
- while (i and -128 != 0) {
- writeByte(i and 127 or 128)
- i = i ushr 7
- }
- writeByte(i)
- }
-}
diff --git a/blockball-bukkit-plugin/bukkit-nms-120R1/build.gradle.kts b/blockball-bukkit-plugin/bukkit-nms-120R1/build.gradle.kts
deleted file mode 100644
index f28b5c081..000000000
--- a/blockball-bukkit-plugin/bukkit-nms-120R1/build.gradle.kts
+++ /dev/null
@@ -1,24 +0,0 @@
-repositories {
- maven(url = "https://libraries.minecraft.net")
-}
-
-dependencies {
- // Dependencies of spigot mojang want to restrict usage to only Java 17. However, we do not care
- // what they want because the general compatibility of this plugin is Java 8. The plugin
- // guarantees that everything works during runtime. This error is a false positive.
- components {
- all {
- allVariants {
- attributes {
- attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
- }
- }
- }
- }
-
- implementation(project(":blockball-api"))
- implementation(project(":blockball-core"))
- compileOnly("com.google.inject:guice:5.0.1")
- compileOnly("org.spigotmc:spigot:1.20.1-R0.1-SNAPSHOT:remapped-mojang")
- testImplementation("org.spigotmc:spigot:1.20.1-R0.1-SNAPSHOT:remapped-mojang")
-}
diff --git a/blockball-bukkit-plugin/bukkit-nms-120R1/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_20_R1/InternalVersionPacket120R1ServiceImpl.kt b/blockball-bukkit-plugin/bukkit-nms-120R1/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_20_R1/InternalVersionPacket120R1ServiceImpl.kt
deleted file mode 100644
index 240533bf2..000000000
--- a/blockball-bukkit-plugin/bukkit-nms-120R1/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_20_R1/InternalVersionPacket120R1ServiceImpl.kt
+++ /dev/null
@@ -1,187 +0,0 @@
-package com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_20_R1
-
-import com.github.shynixn.blockball.api.business.enumeration.CompatibilityArmorSlotType
-import com.github.shynixn.blockball.api.business.proxy.PluginProxy
-import com.github.shynixn.blockball.api.business.service.InternalVersionPacketService
-import com.github.shynixn.blockball.api.persistence.entity.EntityMetaData
-import com.github.shynixn.blockball.api.persistence.entity.Position
-import com.google.inject.Inject
-import com.mojang.datafixers.util.Pair
-import io.netty.buffer.ByteBuf
-import io.netty.buffer.Unpooled
-import net.minecraft.core.Registry
-import net.minecraft.core.registries.BuiltInRegistries
-import net.minecraft.network.FriendlyByteBuf
-import net.minecraft.network.protocol.game.ClientboundAddEntityPacket
-import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket
-import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket
-import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket
-import net.minecraft.world.entity.EntityType
-import net.minecraft.world.entity.EquipmentSlot
-import net.minecraft.world.item.ItemStack
-import java.nio.charset.Charset
-import java.util.*
-
-class InternalVersionPacket120R1ServiceImpl @Inject constructor(
- private val pluginProxy: PluginProxy
-) : InternalVersionPacketService {
- private val craftItemStackNmsMethod by lazy {
- pluginProxy.findClazz("org.bukkit.craftbukkit.VERSION.inventory.CraftItemStack")
- .getDeclaredMethod("asNMSCopy", pluginProxy.findClazz("org.bukkit.inventory.ItemStack"))
- }
- private val enumItemSlotClazz by lazy {
- try {
- pluginProxy.findClazz("net.minecraft.world.entity.EnumItemSlot")
- } catch (e: Exception) {
- pluginProxy.findClazz("net.minecraft.server.VERSION.EnumItemSlot")
- }
- }
- private val mojangPairClazz by lazy {
- pluginProxy.findClazz("com.mojang.datafixers.util.Pair")
- }
-
- /**
- * Creates a new teleport packet.
- */
- override fun createEntityTeleportPacket(entityId: Int, position: Position): Any {
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeBoolean(false)
- return ClientboundTeleportEntityPacket(buffer)
- }
-
- /**
- * Creates a spawn packet.
- */
- override fun createEntitySpawnPacket(entityId: Int, entityType: String, position: Position): Any {
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
-
- val entityUUID = UUID.randomUUID()
- buffer.writeLong(entityUUID.mostSignificantBits)
- buffer.writeLong(entityUUID.leastSignificantBits)
- val nmsEntityType = if (entityType == "ARMOR_STAND") {
- EntityType.ARMOR_STAND
- } else {
- EntityType.SLIME
- }
-
- val registry : Registry> = BuiltInRegistries.ENTITY_TYPE
- val nmsEntityId = registry.getId(nmsEntityType)
-
- buffer.writeId(nmsEntityId)
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte(0)
- buffer.writeId(0)
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
-
- return ClientboundAddEntityPacket(buffer)
- }
-
- /**
- * Creates a entity metadata packet.
- */
- override fun createEntityMetaDataPacket(entityId: Int, entityMetaData: EntityMetaData): Any {
- // https://wiki.vg/Entity_metadata#Entity_Metadata_Format -> Value of Type field. Type of Value = Boolean -> 7.
- val buffer = FriendlyByteBuf(Unpooled.buffer())
- buffer.writeId(entityId)
-
- val byteTypeValue = 0
- val intTypeValue = 1
- val booleanTypeValue = 8
- val optChatTypeValue = 6
- val rotationTypeValue = 9
-
- if (entityMetaData.customNameVisible != null) {
- buffer.writeByte(3)
- buffer.writeId(booleanTypeValue)
- buffer.writeBoolean(entityMetaData.customNameVisible!!)
- }
-
- if (entityMetaData.customname != null) {
- val payload = "{\"text\": \"${entityMetaData.customname}\"}".toByteArray(Charset.forName("UTF-8"))
- buffer.writeByte(2)
- buffer.writeId(optChatTypeValue)
- buffer.writeBoolean(true)
- buffer.writeId(payload.size)
- buffer.writeBytes(payload)
- }
-
- if (entityMetaData.slimeSize != null) {
- val slimeSizeIndex = 16
- buffer.writeByte(slimeSizeIndex)
- buffer.writeId(intTypeValue)
- buffer.writeId(entityMetaData.slimeSize!!)
- }
-
- if (entityMetaData.armorstandHeadRotation != null) {
- buffer.writeByte(16)
- buffer.writeId(rotationTypeValue)
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.x.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.y.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.z.toFloat())
- }
-
- if (entityMetaData.isInvisible != null) {
- buffer.writeByte(0)
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x20)
- }
-
- if (entityMetaData.isSmall != null && entityMetaData.isSmall!!) {
- buffer.writeByte(15)
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x01)
- }
-
- buffer.writeByte(255)
- return ClientboundSetEntityDataPacket(buffer)
- }
-
- /**
- * Creates an entity equipment packet.
- */
- override fun createEntityEquipmentPacket(entityId: Int, slot: CompatibilityArmorSlotType, itemStack: I): Any {
- val nmsItemStack = craftItemStackNmsMethod.invoke(null, itemStack)
- val pair = mojangPairClazz.getDeclaredConstructor(Any::class.java, Any::class.java)
- .newInstance(enumItemSlotClazz.enumConstants[slot.id116], nmsItemStack)
- return ClientboundSetEquipmentPacket(
- entityId,
- mutableListOf(pair) as MutableList>?
- )
- }
-
- /**
- * Mathhelper
- */
- private fun mathhelperA(var0: Double, var2: Double, var4: Double): Double {
- return if (var0 < var2) {
- var2
- } else {
- if (var0 > var4) var4 else var0
- }
- }
-
- /**
- * Writes id.
- */
- private fun ByteBuf.writeId(id: Int) {
- var i = id
- while (i and -128 != 0) {
- writeByte(i and 127 or 128)
- i = i ushr 7
- }
- writeByte(i)
- }
-}
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/BlockBallDependencyInjectionBinder.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/BlockBallDependencyInjectionBinder.kt
index 354f0efed..dbc6fe104 100644
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/BlockBallDependencyInjectionBinder.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/BlockBallDependencyInjectionBinder.kt
@@ -1,7 +1,6 @@
package com.github.shynixn.blockball.bukkit
import com.github.shynixn.blockball.api.business.enumeration.PluginDependency
-import com.github.shynixn.blockball.api.business.enumeration.Version
import com.github.shynixn.blockball.api.business.proxy.PluginProxy
import com.github.shynixn.blockball.api.business.service.*
import com.github.shynixn.blockball.api.persistence.repository.ArenaRepository
@@ -9,22 +8,17 @@ import com.github.shynixn.blockball.api.persistence.repository.LinkSignRepositor
import com.github.shynixn.blockball.bukkit.logic.business.service.*
import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_13_R2.Particle113R2ServiceImpl
import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_13_R2.RayTracingService113R2Impl
-import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_17_R1.InternalVersionPacket117R1ServiceImpl
-import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_17_R1.ScreenMessage117R1ServiceImpl
-import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_18_R1.InternalVersionPacket118R1ServiceImpl
-import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_18_R2.InternalVersionPacket118R2ServiceImpl
-import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_19_R1.InternalVersionPacket119R1ServiceImpl
-import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_19_R2.InternalVersionPacket119R2ServiceImpl
-import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_19_R3.InternalVersionPacket119R3ServiceImpl
-import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_20_R1.InternalVersionPacket120R1ServiceImpl
-import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_8_R3.InternalVersionPacket18R3ServiceImpl
+import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_13_R2.ScreenMessage113R1ServiceImpl
import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_8_R3.Particle18R3ServiceImpl
import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_8_R3.RayTracingService18R3Impl
import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_8_R3.ScreenMessage18R3ServiceImpl
-import com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_9_R2.InternalVersionPacket19R2ServiceImpl
import com.github.shynixn.blockball.core.logic.business.service.*
import com.github.shynixn.blockball.core.logic.persistence.repository.ArenaFileRepository
import com.github.shynixn.blockball.core.logic.persistence.repository.LinkSignFileRepository
+import com.github.shynixn.mcutils.common.Version
+import com.github.shynixn.mcutils.packet.api.EntityService
+import com.github.shynixn.mcutils.packet.api.PacketService
+import com.github.shynixn.mcutils.packet.impl.service.EntityServiceImpl
import com.google.inject.AbstractModule
import com.google.inject.Scopes
import org.bukkit.plugin.Plugin
@@ -32,7 +26,10 @@ import org.bukkit.plugin.Plugin
/**
* BlockBall dependency locator.
*/
-class BlockBallDependencyInjectionBinder(private val plugin: BlockBallPlugin) : AbstractModule() {
+class BlockBallDependencyInjectionBinder(
+ private val plugin: BlockBallPlugin,
+ private val packetService: PacketService
+) : AbstractModule() {
/**
* Configures the business logic tree.
@@ -51,6 +48,8 @@ class BlockBallDependencyInjectionBinder(private val plugin: BlockBallPlugin) :
bind(LinkSignRepository::class.java).to(LinkSignFileRepository::class.java).`in`(Scopes.SINGLETON)
// Services
+ bind(PacketService::class.java).toInstance(packetService)
+ bind(EntityService::class.java).toInstance(EntityServiceImpl())
bind(EventService::class.java).to(EventServiceImpl::class.java).`in`(Scopes.SINGLETON)
bind(TemplateService::class.java).to(TemplateServiceImpl::class.java).`in`(Scopes.SINGLETON)
bind(VirtualArenaService::class.java).to(VirtualArenaServiceImpl::class.java).`in`(Scopes.SINGLETON)
@@ -87,8 +86,6 @@ class BlockBallDependencyInjectionBinder(private val plugin: BlockBallPlugin) :
.`in`(Scopes.SINGLETON)
bind(DependencyService::class.java).to(DependencyServiceImpl::class.java).`in`(Scopes.SINGLETON)
bind(PlaceholderService::class.java).to(PlaceholderServiceImpl::class.java).`in`(Scopes.SINGLETON)
- bind(PacketService::class.java).to(PacketJavaProtocolServiceImpl::class.java).`in`(Scopes.SINGLETON)
- bind(ProtocolService::class.java).to(ProtocolServiceImpl::class.java).`in`(Scopes.SINGLETON)
when {
version.isVersionSameOrGreaterThan(Version.VERSION_1_13_R2)
@@ -100,41 +97,12 @@ class BlockBallDependencyInjectionBinder(private val plugin: BlockBallPlugin) :
when {
version.isVersionSameOrGreaterThan(Version.VERSION_1_17_R1)
- -> bind(ScreenMessageService::class.java).to(ScreenMessage117R1ServiceImpl::class.java)
+ -> bind(ScreenMessageService::class.java).to(ScreenMessage113R1ServiceImpl::class.java)
.`in`(Scopes.SINGLETON)
else -> bind(ScreenMessageService::class.java).to(ScreenMessage18R3ServiceImpl::class.java)
.`in`(Scopes.SINGLETON)
}
- when {
- version.isVersionSameOrGreaterThan(Version.VERSION_1_20_R1) ->
- bind(InternalVersionPacketService::class.java).to(InternalVersionPacket120R1ServiceImpl::class.java)
- .`in`(Scopes.SINGLETON)
- version.isVersionSameOrGreaterThan(Version.VERSION_1_19_R3) ->
- bind(InternalVersionPacketService::class.java).to(InternalVersionPacket119R3ServiceImpl::class.java)
- .`in`(Scopes.SINGLETON)
- version.isVersionSameOrGreaterThan(Version.VERSION_1_19_R2) ->
- bind(InternalVersionPacketService::class.java).to(InternalVersionPacket119R2ServiceImpl::class.java)
- .`in`(Scopes.SINGLETON)
- version.isVersionSameOrGreaterThan(Version.VERSION_1_19_R1) ->
- bind(InternalVersionPacketService::class.java).to(InternalVersionPacket119R1ServiceImpl::class.java)
- .`in`(Scopes.SINGLETON)
- version.isVersionSameOrGreaterThan(Version.VERSION_1_18_R2) ->
- bind(InternalVersionPacketService::class.java).to(InternalVersionPacket118R2ServiceImpl::class.java)
- .`in`(Scopes.SINGLETON)
- version.isVersionSameOrGreaterThan(Version.VERSION_1_18_R1) ->
- bind(InternalVersionPacketService::class.java).to(InternalVersionPacket118R1ServiceImpl::class.java)
- .`in`(Scopes.SINGLETON)
- version.isVersionSameOrGreaterThan(Version.VERSION_1_17_R1) ->
- bind(InternalVersionPacketService::class.java).to(InternalVersionPacket117R1ServiceImpl::class.java)
- .`in`(Scopes.SINGLETON)
- version.isVersionSameOrGreaterThan(Version.VERSION_1_9_R1)
- -> bind(InternalVersionPacketService::class.java).to(InternalVersionPacket19R2ServiceImpl::class.java)
- .`in`(Scopes.SINGLETON)
- else -> bind(InternalVersionPacketService::class.java).to(InternalVersionPacket18R3ServiceImpl::class.java)
- .`in`(Scopes.SINGLETON)
- }
-
when {
version.isVersionSameOrGreaterThan(Version.VERSION_1_13_R2) -> bind(ParticleService::class.java).to(
Particle113R2ServiceImpl::class.java
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/BlockBallPlugin.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/BlockBallPlugin.kt
index 267d116ae..0a280ab95 100644
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/BlockBallPlugin.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/BlockBallPlugin.kt
@@ -5,13 +5,16 @@ package com.github.shynixn.blockball.bukkit
import com.github.shynixn.blockball.api.BlockBallApi
import com.github.shynixn.blockball.api.business.enumeration.ChatColor
import com.github.shynixn.blockball.api.business.enumeration.PluginDependency
-import com.github.shynixn.blockball.api.business.enumeration.Version
import com.github.shynixn.blockball.api.business.proxy.PluginProxy
import com.github.shynixn.blockball.api.business.service.*
import com.github.shynixn.blockball.bukkit.logic.business.listener.*
import com.github.shynixn.blockball.core.logic.business.commandexecutor.*
import com.github.shynixn.blockball.core.logic.business.extension.cast
import com.github.shynixn.blockball.core.logic.business.extension.translateChatColors
+import com.github.shynixn.mcutils.common.Version
+import com.github.shynixn.mcutils.packet.api.PacketInType
+import com.github.shynixn.mcutils.packet.api.PacketService
+import com.github.shynixn.mcutils.packet.impl.PacketServiceImpl
import com.google.inject.Guice
import com.google.inject.Injector
import org.apache.commons.io.IOUtils
@@ -37,7 +40,7 @@ class BlockBallPlugin : JavaPlugin(), PluginProxy {
private var injector: Injector? = null
private var serverVersion: Version? = null
private val bstatsPluginId = 1317
- private val versionFlag = "###VERSION###"
+ private var packetService : PacketService? = null
/**
* Gets the installed version of the plugin.
@@ -70,7 +73,11 @@ class BlockBallPlugin : JavaPlugin(), PluginProxy {
return
}
- val versions = if (versionFlag == "all") {
+ val useLegacy = getResource("plugin.yml")!!.bufferedReader().use { reader ->
+ !reader.readText().contains("api-version")
+ }
+
+ val versions = if (useLegacy) {
arrayOf(
Version.VERSION_1_8_R3,
Version.VERSION_1_9_R2,
@@ -90,14 +97,15 @@ class BlockBallPlugin : JavaPlugin(), PluginProxy {
Version.VERSION_1_19_R2,
Version.VERSION_1_19_R3,
Version.VERSION_1_20_R1,
+ Version.VERSION_1_20_R2,
)
} else {
arrayOf(
- Version.VERSION_1_20_R1,
+ Version.VERSION_1_20_R2,
)
}
- if (!getServerVersion().isCompatible(*versions)) {
+ if (!Version.serverVersion.isCompatible(*versions)) {
sendConsoleMessage(ChatColor.RED.toString() + "================================================")
sendConsoleMessage(ChatColor.RED.toString() + "BlockBall does not support your server version")
sendConsoleMessage(ChatColor.RED.toString() + "Install v" + versions[0].id + " - v" + versions[versions.size - 1].id)
@@ -108,7 +116,8 @@ class BlockBallPlugin : JavaPlugin(), PluginProxy {
return
}
- this.injector = Guice.createInjector(BlockBallDependencyInjectionBinder(this))
+ this.packetService = PacketServiceImpl(this)
+ this.injector = Guice.createInjector(BlockBallDependencyInjectionBinder(this, packetService!!))
this.reloadConfig()
// Register Listeners
@@ -172,24 +181,10 @@ class BlockBallPlugin : JavaPlugin(), PluginProxy {
.consoleSender.sendMessage(PREFIX_CONSOLE + ChatColor.DARK_GREEN + "Started server linking.")
}
- val protocolService = resolve(ProtocolService::class.java)
-
- for (world in Bukkit.getWorlds()) {
- for (player in world.players) {
- protocolService.register(player)
- }
- }
-
- val packetPlayInUseClazz = try {
- findClazz("net.minecraft.network.protocol.game.PacketPlayInUseEntity")
- } catch (e: Exception) {
- findClazz("net.minecraft.server.VERSION.PacketPlayInUseEntity")
- }
-
- protocolService.registerPackets(listOf(packetPlayInUseClazz))
+ packetService!!.registerPacketListening(PacketInType.USEENTITY)
Bukkit.getServer()
- .consoleSender.sendMessage(PREFIX_CONSOLE + ChatColor.GREEN + "Enabled BlockBall " + this.description.version + " by Shynixn, LazoYoung")
+ .consoleSender.sendMessage(PREFIX_CONSOLE + ChatColor.GREEN + "Enabled BlockBall " + this.description.version + " by Shynixn")
}
/**
@@ -200,7 +195,7 @@ class BlockBallPlugin : JavaPlugin(), PluginProxy {
return
}
- resolve(ProtocolService::class.java).dispose()
+ packetService!!.close()
try {
resolve(GameService::class.java).close()
@@ -315,7 +310,7 @@ class BlockBallPlugin : JavaPlugin(), PluginProxy {
return Class.forName(
name.replace(
"VERSION",
- BlockBallApi.resolve(PluginProxy::class.java).getServerVersion().bukkitId
+ (BlockBallApi.resolve(PluginProxy::class.java).getServerVersion() as Version).bukkitId
)
)
}
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/extension/ExtensionMethod.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/extension/ExtensionMethod.kt
index 3f8dc5e72..ba00b1aaf 100644
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/extension/ExtensionMethod.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/extension/ExtensionMethod.kt
@@ -7,9 +7,11 @@ import com.github.shynixn.blockball.api.business.enumeration.Permission
import com.github.shynixn.blockball.api.business.proxy.PluginProxy
import com.github.shynixn.blockball.api.persistence.entity.Position
import com.github.shynixn.blockball.core.logic.persistence.entity.PositionEntity
+import com.github.shynixn.mcutils.common.Version
import org.bukkit.Bukkit
import org.bukkit.Location
import org.bukkit.entity.Player
+import org.bukkit.plugin.Plugin
import org.bukkit.util.Vector
/**
@@ -45,11 +47,15 @@ fun findClazz(name: String): Class<*> {
return Class.forName(
name.replace(
"VERSION",
- BlockBallApi.resolve(PluginProxy::class.java).getServerVersion().bukkitId
+ (BlockBallApi.resolve(PluginProxy::class.java).getServerVersion() as Version).bukkitId
)
)
}
+fun PluginProxy.getCompatibilityServerVersion(): Version {
+ return (this as PluginProxy).getServerVersion() as Version
+}
+
/**
* Converts the given position to a bukkit Location.
*/
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/listener/BallListener.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/listener/BallListener.kt
index 699012d73..0c3360a5f 100644
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/listener/BallListener.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/listener/BallListener.kt
@@ -7,14 +7,11 @@ import com.github.shynixn.blockball.api.business.enumeration.BallActionType
import com.github.shynixn.blockball.api.business.proxy.BallProxy
import com.github.shynixn.blockball.api.business.service.BallEntityService
import com.github.shynixn.blockball.api.business.service.ParticleService
-import com.github.shynixn.blockball.api.business.service.ProtocolService
import com.github.shynixn.blockball.api.business.service.SoundService
import com.google.inject.Inject
import org.bukkit.Location
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
-import org.bukkit.event.player.PlayerJoinEvent
-import org.bukkit.event.player.PlayerQuitEvent
/**
* Handles common ball events.
@@ -22,25 +19,8 @@ import org.bukkit.event.player.PlayerQuitEvent
class BallListener @Inject constructor(
private val ballEntityService: BallEntityService,
private val particleService: ParticleService,
- private val soundService: SoundService,
- private val protocolService: ProtocolService
+ private val soundService: SoundService
) : Listener {
- /**
- * Registers the player on join.
- */
- @EventHandler
- fun onPlayerJoinEvent(event: PlayerJoinEvent) {
- protocolService.register(event.player)
- }
-
- /**
- * Unregisters the player on leave.
- */
- @EventHandler
- fun playerQuitEvent(event: PlayerQuitEvent) {
- protocolService.unRegister(event.player)
- }
-
/**
* Gets called when the ball raytraces in the world.
*/
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/listener/GameListener.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/listener/GameListener.kt
index 180f7ba10..344811246 100644
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/listener/GameListener.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/listener/GameListener.kt
@@ -2,17 +2,18 @@ package com.github.shynixn.blockball.bukkit.logic.business.listener
import com.github.shynixn.blockball.api.bukkit.event.BallRayTraceEvent
import com.github.shynixn.blockball.api.bukkit.event.BallTouchEvent
-import com.github.shynixn.blockball.api.bukkit.event.PacketEvent
import com.github.shynixn.blockball.api.business.enumeration.Permission
import com.github.shynixn.blockball.api.business.enumeration.Team
import com.github.shynixn.blockball.api.business.service.*
import com.github.shynixn.blockball.api.persistence.entity.HubGame
-import com.github.shynixn.blockball.bukkit.logic.business.extension.findClazz
import com.github.shynixn.blockball.bukkit.logic.business.extension.hasPermission
import com.github.shynixn.blockball.bukkit.logic.business.extension.toLocation
import com.github.shynixn.blockball.bukkit.logic.business.extension.toPosition
-import com.github.shynixn.blockball.core.logic.business.extension.accessible
import com.github.shynixn.blockball.core.logic.business.extension.sync
+import com.github.shynixn.mcutils.packet.api.InteractionType
+import com.github.shynixn.mcutils.packet.api.PacketInType
+import com.github.shynixn.mcutils.packet.api.event.PacketEvent
+import com.github.shynixn.mcutils.packet.api.packet.PacketInInteractEntity
import com.google.inject.Inject
import org.bukkit.block.Sign
import org.bukkit.entity.Player
@@ -25,7 +26,6 @@ import org.bukkit.event.entity.PlayerDeathEvent
import org.bukkit.event.inventory.InventoryClickEvent
import org.bukkit.event.inventory.InventoryOpenEvent
import org.bukkit.event.player.*
-import java.util.function.Function
/**
* Game Listener for the most important game events.
@@ -41,55 +41,30 @@ class GameListener @Inject constructor(
private val ballEntityService: BallEntityService
) : Listener {
private val playerCache = HashSet()
- private val packetPlayInUseEntityActionFun: Function by lazy {
- try {
- val field = findClazz("net.minecraft.network.protocol.game.PacketPlayInUseEntity")
- .getDeclaredField("b").accessible(true)
- Function { packet ->
- val data = field.get(packet)
- val method = data::class.java.getDeclaredMethod("a")
- method.isAccessible = true
- method.invoke(data)
- }
- } catch (e: Exception) {
- val field = findClazz("net.minecraft.server.VERSION.PacketPlayInUseEntity")
- .getDeclaredField("action").accessible(true)
- Function { packet ->
- field.get(packet)
- }
- }
- }
- private val packetPlayInUseEntityIdField by lazy {
- try {
- findClazz("net.minecraft.network.protocol.game.PacketPlayInUseEntity")
- .getDeclaredField("a").accessible(true)
- } catch (e: Exception) {
- findClazz("net.minecraft.server.VERSION.PacketPlayInUseEntity")
- .getDeclaredField("a").accessible(true)
- }
- }
/**
* Gets called when a packet arrives.
*/
@EventHandler
fun onPacketEvent(event: PacketEvent) {
+ if (event.packetType != PacketInType.USEENTITY) {
+ return
+ }
+
val game = gameService.getGameFromPlayer(event.player)
if (!game.isPresent) {
return
}
- val action = packetPlayInUseEntityActionFun.apply(event.packet)
- val entityId = packetPlayInUseEntityIdField.get(event.packet) as Int
- val ball = ballEntityService.findBallByEntityId(entityId) ?: return
- val isPass = action.toString() != "ATTACK"
+ val packet = event.packet as PacketInInteractEntity
+ val ball = ballEntityService.findBallByEntityId(packet.entityId) ?: return
if (game.get().ball != ball) {
return
}
- if (isPass) {
+ if (packet.actionType == InteractionType.RIGHT_CLICK) {
ball.passByPlayer(event.player)
} else {
ball.kickByPlayer(event.player)
diff --git a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/proxy/AllPlayerTracker.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/proxy/AllPlayerTracker.kt
similarity index 95%
rename from blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/proxy/AllPlayerTracker.kt
rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/proxy/AllPlayerTracker.kt
index f27c4d086..a40b3b938 100644
--- a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/proxy/AllPlayerTracker.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/proxy/AllPlayerTracker.kt
@@ -1,4 +1,4 @@
-package com.github.shynixn.blockball.core.logic.business.proxy
+package com.github.shynixn.blockball.bukkit.logic.business.proxy
import com.github.shynixn.blockball.api.business.service.ProxyService
import com.github.shynixn.blockball.api.persistence.entity.Position
diff --git a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/proxy/BallCrossPlatformProxy.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/proxy/BallCrossPlatformProxy.kt
similarity index 98%
rename from blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/proxy/BallCrossPlatformProxy.kt
rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/proxy/BallCrossPlatformProxy.kt
index b9422facc..efd2c9da5 100644
--- a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/proxy/BallCrossPlatformProxy.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/proxy/BallCrossPlatformProxy.kt
@@ -1,6 +1,6 @@
@file:Suppress("UNCHECKED_CAST")
-package com.github.shynixn.blockball.core.logic.business.proxy
+package com.github.shynixn.blockball.bukkit.logic.business.proxy
import com.github.shynixn.blockball.api.business.proxy.BallProxy
import com.github.shynixn.blockball.api.business.service.EventService
diff --git a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/proxy/BallDesignEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/proxy/BallDesignEntity.kt
similarity index 56%
rename from blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/proxy/BallDesignEntity.kt
rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/proxy/BallDesignEntity.kt
index 8974d00ef..da59e71c6 100644
--- a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/proxy/BallDesignEntity.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/proxy/BallDesignEntity.kt
@@ -1,18 +1,26 @@
@file:Suppress("UNCHECKED_CAST")
-package com.github.shynixn.blockball.core.logic.business.proxy
+package com.github.shynixn.blockball.bukkit.logic.business.proxy
import com.github.shynixn.blockball.api.business.enumeration.BallSize
-import com.github.shynixn.blockball.api.business.enumeration.CompatibilityArmorSlotType
import com.github.shynixn.blockball.api.business.enumeration.MaterialType
import com.github.shynixn.blockball.api.business.proxy.BallProxy
import com.github.shynixn.blockball.api.business.service.ItemTypeService
-import com.github.shynixn.blockball.api.business.service.PacketService
import com.github.shynixn.blockball.api.business.service.ProxyService
import com.github.shynixn.blockball.api.persistence.entity.Position
-import com.github.shynixn.blockball.core.logic.persistence.entity.EntityMetadataImpl
+import com.github.shynixn.blockball.bukkit.logic.business.extension.toLocation
+import com.github.shynixn.blockball.bukkit.logic.business.extension.toVector
import com.github.shynixn.blockball.core.logic.persistence.entity.ItemEntity
import com.github.shynixn.blockball.core.logic.persistence.entity.PositionEntity
+import com.github.shynixn.mcutils.common.Vector3d
+import com.github.shynixn.mcutils.common.toEulerAngle
+import com.github.shynixn.mcutils.common.toVector3d
+import com.github.shynixn.mcutils.packet.api.ArmorSlotType
+import com.github.shynixn.mcutils.packet.api.EntityType
+import com.github.shynixn.mcutils.packet.api.PacketService
+import com.github.shynixn.mcutils.packet.api.packet.*
+import org.bukkit.entity.Player
+import org.bukkit.inventory.ItemStack
class BallDesignEntity(val entityId: Int) {
private val helmetItemStack by lazy {
@@ -55,20 +63,24 @@ class BallDesignEntity(val entityId: Int) {
* Spawns the ball for the given player.
*/
fun spawn(player: Any, position: Position) {
- packetService.sendEntitySpawnPacket(player, entityId, "ARMOR_STAND", position)
+ require(player is Player)
+ packetService.sendPacketOutEntitySpawn(player, PacketOutEntitySpawn().also {
+ it.target = position.toLocation()
+ it.entityId = entityId
+ it.entityType = EntityType.ARMOR_STAND
+ })
if (!ball.meta.isSlimeVisible) {
- packetService.sendEntityEquipmentPacket(
- player,
- entityId,
- CompatibilityArmorSlotType.HELMET,
- helmetItemStack
- )
+ packetService.sendPacketOutEntityEquipment(player, PacketOutEntityEquipment().also {
+ it.entityId = entityId
+ it.items = listOf(Pair(ArmorSlotType.HELMET, helmetItemStack as ItemStack))
+ })
}
- packetService.sendEntityMetaDataPacket(player, entityId, EntityMetadataImpl {
- this.isInvisible = true
- this.isSmall = ball.meta.size == BallSize.SMALL
+ packetService.sendPacketOutEntityMetadata(player, PacketOutEntityMetadata().also {
+ it.entityId = entityId
+ it.isInvisible = true
+ it.isArmorstandSmall = ball.meta.size == BallSize.SMALL
})
}
@@ -76,7 +88,10 @@ class BallDesignEntity(val entityId: Int) {
* Destroys the ball for the given player.
*/
fun destroy(player: Any) {
- packetService.sendEntityDestroyPacket(player, entityId)
+ require(player is Player)
+ packetService.sendPacketOutEntityDestroy(player, PacketOutEntityDestroy().also {
+ it.entityIds = listOf(entityId)
+ })
}
/**
@@ -93,7 +108,11 @@ class BallDesignEntity(val entityId: Int) {
}
for (player in players) {
- packetService.sendEntityTeleportPacket(player, entityId, position)
+ require(player is Player)
+ packetService.sendPacketOutTeleport(player, PacketOutEntityTeleport().also {
+ it.entityId = entityId
+ it.target = position.toLocation()
+ })
}
if (ball.meta.rotating) {
@@ -116,22 +135,24 @@ class BallDesignEntity(val entityId: Int) {
}
val angle = when {
- length > 1.0 -> PositionEntity(rotation.x - 30, 0.0, 0.0)
- length > 0.1 -> PositionEntity(rotation.x - 10, 0.0, 0.0)
- length > 0.08 -> PositionEntity(rotation.x - 5, 0.0, 0.0)
+ length > 1.0 -> Vector3d(rotation.x - 30, 0.0, 0.0)
+ length > 0.1 -> Vector3d(rotation.x - 10, 0.0, 0.0)
+ length > 0.08 -> Vector3d(rotation.x - 5, 0.0, 0.0)
else -> null
}
if (angle != null) {
- rotation = angle
+ rotation = PositionEntity(angle.x, angle.y, angle.z)
if (ball.meta.isSlimeVisible) {
return
}
for (player in players) {
- packetService.sendEntityMetaDataPacket(player, entityId, EntityMetadataImpl {
- this.armorstandHeadRotation = rotation
+ require(player is Player)
+ packetService.sendPacketOutEntityMetadata(player, PacketOutEntityMetadata().also {
+ it.armorStandHeadRotation = angle.toEulerAngle()
+ it.entityId = entityId
})
}
}
diff --git a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/proxy/BallHitboxEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/proxy/BallHitboxEntity.kt
similarity index 86%
rename from blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/proxy/BallHitboxEntity.kt
rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/proxy/BallHitboxEntity.kt
index 3b510fe72..8f1abc9e0 100644
--- a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/proxy/BallHitboxEntity.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/proxy/BallHitboxEntity.kt
@@ -1,10 +1,12 @@
-package com.github.shynixn.blockball.core.logic.business.proxy
+package com.github.shynixn.blockball.bukkit.logic.business.proxy
import com.github.shynixn.blockball.api.business.enumeration.BlockDirection
import com.github.shynixn.blockball.api.business.enumeration.GameMode
import com.github.shynixn.blockball.api.business.service.*
import com.github.shynixn.blockball.api.persistence.entity.BallMeta
import com.github.shynixn.blockball.api.persistence.entity.Position
+import com.github.shynixn.blockball.bukkit.logic.business.extension.toLocation
+import com.github.shynixn.blockball.bukkit.logic.business.extension.toVector
import com.github.shynixn.blockball.core.logic.business.extension.sync
import com.github.shynixn.blockball.core.logic.persistence.entity.EntityMetadataImpl
import com.github.shynixn.blockball.core.logic.persistence.entity.PositionEntity
@@ -12,6 +14,10 @@ import com.github.shynixn.blockball.core.logic.persistence.event.BallKickEventEn
import com.github.shynixn.blockball.core.logic.persistence.event.BallPassEventEntity
import com.github.shynixn.blockball.core.logic.persistence.event.BallRayTraceEventEntity
import com.github.shynixn.blockball.core.logic.persistence.event.BallTouchEventEntity
+import com.github.shynixn.mcutils.packet.api.EntityType
+import com.github.shynixn.mcutils.packet.api.PacketService
+import com.github.shynixn.mcutils.packet.api.packet.*
+import org.bukkit.entity.Player
import kotlin.math.abs
import kotlin.math.atan2
import kotlin.math.cos
@@ -100,16 +106,23 @@ class BallHitboxEntity(val entityId: Int) {
* Spawns the ball for the given player.
*/
fun spawn(player: Any, position: Position) {
- packetService.sendEntitySpawnPacket(player, entityId, "SLIME", position)
+ require(player is Player)
+ packetService.sendPacketOutEntitySpawn(player, PacketOutEntitySpawn().also {
+ it.entityId = entityId
+ it.entityType = EntityType.SLIME
+ it.target = position.toLocation()
+ })
if (meta.isSlimeVisible) {
- packetService.sendEntityMetaDataPacket(player, entityId, EntityMetadataImpl {
- this.slimeSize = meta.kickPassHitBoxSize.toInt()
+ packetService.sendPacketOutEntityMetadata(player, PacketOutEntityMetadata().also {
+ it.slimeSize = meta.kickPassHitBoxSize.toInt()
+ it.entityId = entityId
})
} else {
- packetService.sendEntityMetaDataPacket(player, entityId, EntityMetadataImpl {
- this.isInvisible = true
- this.slimeSize = meta.kickPassHitBoxSize.toInt()
+ packetService.sendPacketOutEntityMetadata(player, PacketOutEntityMetadata().also {
+ it.slimeSize = meta.kickPassHitBoxSize.toInt()
+ it.entityId = entityId
+ it.isInvisible = true
})
}
}
@@ -118,7 +131,10 @@ class BallHitboxEntity(val entityId: Int) {
* Destroys the ball for the given player.
*/
fun destroy(player: Any) {
- packetService.sendEntityDestroyPacket(player, entityId)
+ require(player is Player)
+ packetService.sendPacketOutEntityDestroy(player, PacketOutEntityDestroy().also {
+ it.entityIds = listOf(entityId)
+ })
}
/**
@@ -156,7 +172,11 @@ class BallHitboxEntity(val entityId: Int) {
// Visible position makes the slime hitbox better align with the ball.
val visiblePosition = position.clone().add(0.0, -0.5, 0.0).add(0.0, meta.hitBoxRelocation, 0.0)
for (player in players) {
- packetService.sendEntityTeleportPacket(player, entityId, visiblePosition)
+ require(player is Player)
+ packetService.sendPacketOutTeleport(player, PacketOutEntityTeleport().also {
+ it.entityId = entityId
+ it.target = visiblePosition.toLocation()
+ })
}
motion = PositionEntity(0.0, -0.7, 0.0)
@@ -287,7 +307,11 @@ class BallHitboxEntity(val entityId: Int) {
motion.y = 0.0
for (player in players) {
- packetService.sendEntityVelocityPacket(player, entityId, motion)
+ require(player is Player)
+ packetService.sendPacketOutVelocity(player, PacketOutEntityVelocity().also {
+ it.entityId = entityId
+ it.target = motion.toVector()
+ })
}
this.position = targetPosition
@@ -295,7 +319,11 @@ class BallHitboxEntity(val entityId: Int) {
// Visible position makes the slime hitbox better align with the ball.
val visiblePosition = position.clone().add(0.0, -0.5, 0.0).add(0.0, meta.hitBoxRelocation, 0.0)
for (player in players) {
- packetService.sendEntityTeleportPacket(player, entityId, visiblePosition)
+ require(player is Player)
+ packetService.sendPacketOutTeleport(player, PacketOutEntityTeleport().also {
+ it.entityId = entityId
+ it.target = visiblePosition.toLocation()
+ })
}
val rollingResistance = 1.0 - this.meta.movementModifier.rollingResistance
@@ -316,7 +344,11 @@ class BallHitboxEntity(val entityId: Int) {
// Visible position makes the slime hitbox better align with the ball.
val visiblePosition = position.clone().add(0.0, -0.5, 0.0).add(0.0, meta.hitBoxRelocation, 0.0)
for (player in players) {
- packetService.sendEntityTeleportPacket(player, entityId, visiblePosition)
+ require(player is Player)
+ packetService.sendPacketOutTeleport(player, PacketOutEntityTeleport().also {
+ it.entityId = entityId
+ it.target = visiblePosition.toLocation()
+ })
}
// Handles angular velocity spinning in air.
diff --git a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/proxy/PacketHologram.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/proxy/PacketHologram.kt
similarity index 66%
rename from blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/proxy/PacketHologram.kt
rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/proxy/PacketHologram.kt
index 435b0b402..e290a8c06 100644
--- a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/proxy/PacketHologram.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/proxy/PacketHologram.kt
@@ -1,11 +1,16 @@
-package com.github.shynixn.blockball.core.logic.business.proxy
+package com.github.shynixn.blockball.bukkit.logic.business.proxy
import com.github.shynixn.blockball.api.business.proxy.HologramProxy
-import com.github.shynixn.blockball.api.business.service.PacketService
import com.github.shynixn.blockball.api.business.service.ProxyService
import com.github.shynixn.blockball.api.persistence.entity.Position
-import com.github.shynixn.blockball.core.logic.persistence.entity.EntityMetadataImpl
+import com.github.shynixn.blockball.bukkit.logic.business.extension.toLocation
import com.github.shynixn.blockball.core.logic.persistence.entity.PositionEntity
+import com.github.shynixn.mcutils.packet.api.EntityType
+import com.github.shynixn.mcutils.packet.api.PacketService
+import com.github.shynixn.mcutils.packet.api.packet.PacketOutEntityDestroy
+import com.github.shynixn.mcutils.packet.api.packet.PacketOutEntityMetadata
+import com.github.shynixn.mcutils.packet.api.packet.PacketOutEntitySpawn
+import org.bukkit.entity.Player
class PacketHologram : HologramProxy {
private var position: Position? = null
@@ -16,10 +21,12 @@ class PacketHologram : HologramProxy {
{
position!!
}, { player ->
+ require(player is Player)
sendSpawn(player)
sendUpdateMetaData(player)
},
{ player ->
+ require(player is Player)
sendDestroy(player)
if (players.contains(player)) {
@@ -95,6 +102,7 @@ class PacketHologram : HologramProxy {
val players = playerTracker.checkAndGet()
for (player in players) {
+ require(player is Player)
sendUpdateMetaData(player)
}
}
@@ -116,28 +124,27 @@ class PacketHologram : HologramProxy {
/**
* Sends a spawn packet.
*/
- private fun sendSpawn(player: Any) {
+ private fun sendSpawn(player: Player) {
for (i in 0 until entityIds.size) {
val upSet = i * 0.24
-
- packetService.sendEntitySpawnPacket(
- player,
- entityIds[i],
- "ARMOR_STAND",
- PositionEntity(this.position!!.x, this.position!!.y - upSet, this.position!!.z)
- )
+ packetService.sendPacketOutEntitySpawn(player, PacketOutEntitySpawn().also {
+ it.entityId = entityIds[i]
+ it.entityType = EntityType.ARMOR_STAND
+ it.target = PositionEntity(this.position!!.worldName!!, this.position!!.x, this.position!!.y - upSet, this.position!!.z).toLocation()
+ })
}
}
/**
* Updates the metadata.
*/
- private fun sendUpdateMetaData(player: Any) {
+ private fun sendUpdateMetaData(player: Player) {
for (i in 0 until entityIds.size) {
- packetService.sendEntityMetaDataPacket(player, entityIds[i], EntityMetadataImpl {
- this.customNameVisible = true
- this.customname = lines[i]
- this.isInvisible = true
+ packetService.sendPacketOutEntityMetadata(player, PacketOutEntityMetadata().also {
+ it.entityId = entityIds[i]
+ it.customname = lines[i]
+ it.customNameVisible = true
+ it.isInvisible = true
})
}
}
@@ -145,9 +152,9 @@ class PacketHologram : HologramProxy {
/**
* Sends destroy.
*/
- private fun sendDestroy(player: Any) {
- for (i in 0 until entityIds.size) {
- packetService.sendEntityDestroyPacket(player, entityIds[i])
- }
+ private fun sendDestroy(player: Player) {
+ packetService.sendPacketOutEntityDestroy(player, PacketOutEntityDestroy().also {
+ it.entityIds = entityIds
+ })
}
}
diff --git a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/service/BallEntityServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/BallEntityServiceImpl.kt
similarity index 90%
rename from blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/service/BallEntityServiceImpl.kt
rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/BallEntityServiceImpl.kt
index 3b65fa03c..135e91f95 100644
--- a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/service/BallEntityServiceImpl.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/BallEntityServiceImpl.kt
@@ -1,12 +1,13 @@
-package com.github.shynixn.blockball.core.logic.business.service
+package com.github.shynixn.blockball.bukkit.logic.business.service
import com.github.shynixn.blockball.api.business.proxy.BallProxy
import com.github.shynixn.blockball.api.business.service.*
import com.github.shynixn.blockball.api.persistence.entity.BallMeta
-import com.github.shynixn.blockball.core.logic.business.proxy.BallCrossPlatformProxy
-import com.github.shynixn.blockball.core.logic.business.proxy.BallDesignEntity
-import com.github.shynixn.blockball.core.logic.business.proxy.BallHitboxEntity
+import com.github.shynixn.blockball.bukkit.logic.business.proxy.BallCrossPlatformProxy
+import com.github.shynixn.blockball.bukkit.logic.business.proxy.BallDesignEntity
+import com.github.shynixn.blockball.bukkit.logic.business.proxy.BallHitboxEntity
import com.github.shynixn.blockball.core.logic.persistence.event.BallSpawnEventEntity
+import com.github.shynixn.mcutils.packet.api.PacketService
import com.google.inject.Inject
class BallEntityServiceImpl @Inject constructor(
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/BossBarServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/BossBarServiceImpl.kt
index f8631ce01..57f3e4a95 100644
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/BossBarServiceImpl.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/BossBarServiceImpl.kt
@@ -3,12 +3,13 @@
package com.github.shynixn.blockball.bukkit.logic.business.service
import com.github.shynixn.blockball.api.business.enumeration.BossBarFlag
-import com.github.shynixn.blockball.api.business.enumeration.Version
import com.github.shynixn.blockball.api.business.proxy.PluginProxy
import com.github.shynixn.blockball.api.business.service.BossBarService
import com.github.shynixn.blockball.api.business.service.DependencyBossBarApiService
import com.github.shynixn.blockball.api.persistence.entity.BossBarMeta
+import com.github.shynixn.blockball.bukkit.logic.business.extension.getCompatibilityServerVersion
import com.github.shynixn.blockball.core.logic.business.extension.translateChatColors
+import com.github.shynixn.mcutils.common.Version
import com.google.inject.Inject
import org.bukkit.Bukkit
import org.bukkit.entity.Player
@@ -49,7 +50,7 @@ class BossBarServiceImpl @Inject constructor(private val plugin: PluginProxy, pr
* Does nothing if the player is already added.
*/
override fun addPlayer(bossBar: B, player: P) {
- if (plugin.getServerVersion().isVersionSameOrLowerThan(Version.VERSION_1_8_R3)) {
+ if (plugin.getCompatibilityServerVersion().isVersionSameOrLowerThan(Version.VERSION_1_8_R3)) {
dependencyBossBarService.setBossbarMessage(player, "", 1.0)
} else {
if (!getPlayers(bossBar).contains(player)) {
@@ -63,7 +64,7 @@ class BossBarServiceImpl @Inject constructor(private val plugin: PluginProxy, pr
* Does nothing if the player is already removed.
*/
override fun removePlayer(bossBar: B, player: P) {
- if (plugin.getServerVersion().isVersionSameOrLowerThan(Version.VERSION_1_8_R3)) {
+ if (plugin.getCompatibilityServerVersion().isVersionSameOrLowerThan(Version.VERSION_1_8_R3)) {
dependencyBossBarService.removeBossbarMessage(player)
} else {
if (getPlayers(bossBar).contains(player)) {
@@ -76,7 +77,7 @@ class BossBarServiceImpl @Inject constructor(private val plugin: PluginProxy, pr
* Returns a list of all players watching thie bossbar.
*/
override fun getPlayers(bossBar: B): List {
- return if (plugin.getServerVersion().isVersionSameOrLowerThan(Version.VERSION_1_8_R3)) {
+ return if (plugin.getCompatibilityServerVersion().isVersionSameOrLowerThan(Version.VERSION_1_8_R3)) {
ArrayList()
} else {
getBossBarMethod("getPlayers").invoke(bossBar) as List
@@ -87,7 +88,7 @@ class BossBarServiceImpl @Inject constructor(private val plugin: PluginProxy, pr
* Changes the style of the bossbar with given [bossBarMeta].
*/
override fun changeConfiguration(bossBar: B, title: String, bossBarMeta: BossBarMeta, player: P) {
- if (plugin.getServerVersion().isVersionSameOrLowerThan(Version.VERSION_1_8_R3) && player != null) {
+ if (plugin.getCompatibilityServerVersion().isVersionSameOrLowerThan(Version.VERSION_1_8_R3) && player != null) {
dependencyBossBarService.setBossbarMessage(player, bossBarMeta.message.translateChatColors(), bossBarMeta.percentage)
} else {
getBossBarMethod("setVisible", Boolean::class.java).invoke(bossBar, bossBarMeta.enabled)
@@ -148,4 +149,4 @@ class BossBarServiceImpl @Inject constructor(private val plugin: PluginProxy, pr
private fun getBossBarMethod(name: String, vararg clazzes: Class<*>): Method {
return Class.forName("org.bukkit.boss.BossBar").getDeclaredMethod(name, *clazzes)
}
-}
\ No newline at end of file
+}
diff --git a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/service/GameActionServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/GameActionServiceImpl.kt
similarity index 97%
rename from blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/service/GameActionServiceImpl.kt
rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/GameActionServiceImpl.kt
index d0a90175e..fa1b86d3a 100644
--- a/blockball-core/src/main/java/com/github/shynixn/blockball/core/logic/business/service/GameActionServiceImpl.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/GameActionServiceImpl.kt
@@ -1,15 +1,18 @@
@file:Suppress("UNCHECKED_CAST")
-package com.github.shynixn.blockball.core.logic.business.service
+package com.github.shynixn.blockball.bukkit.logic.business.service
import com.github.shynixn.blockball.api.BlockBallApi
import com.github.shynixn.blockball.api.business.enumeration.*
import com.github.shynixn.blockball.api.business.proxy.PluginProxy
import com.github.shynixn.blockball.api.business.service.*
import com.github.shynixn.blockball.api.persistence.entity.*
-import com.github.shynixn.blockball.core.logic.business.proxy.PacketHologram
+import com.github.shynixn.blockball.bukkit.logic.business.extension.getCompatibilityServerVersion
+import com.github.shynixn.blockball.bukkit.logic.business.proxy.PacketHologram
import com.github.shynixn.blockball.core.logic.persistence.event.GameJoinEventEntity
import com.github.shynixn.blockball.core.logic.persistence.event.GameLeaveEventEntity
+import com.github.shynixn.mcutils.common.Version
+import com.github.shynixn.mcutils.packet.api.PacketService
import com.google.inject.Inject
/**
@@ -56,7 +59,6 @@ class GameActionServiceImpl @Inject constructor(
private val proxyService: ProxyService,
private val loggingService: LoggingService,
private val packetService: PacketService,
- private val concurrencyService: ConcurrencyService
) : GameActionService {
private val prefix = configurationService.findValue("messages.prefix")
@@ -393,7 +395,7 @@ class GameActionServiceImpl @Inject constructor(
*/
private fun updateBossBar(game: Game) {
val meta = game.arena.meta.bossBarMeta
- if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_9_R1)) {
+ if (pluginProxy.getCompatibilityServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_9_R1)) {
if (game.bossBar == null && game.arena.meta.bossBarMeta.enabled) {
game.bossBar = bossBarService.createNewBossBar(game.arena.meta.bossBarMeta)
}
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/ItemTypeServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/ItemTypeServiceImpl.kt
index 48ef3cb5d..e0703813c 100644
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/ItemTypeServiceImpl.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/ItemTypeServiceImpl.kt
@@ -3,12 +3,12 @@
package com.github.shynixn.blockball.bukkit.logic.business.service
import com.github.shynixn.blockball.api.business.enumeration.MaterialType
-import com.github.shynixn.blockball.api.business.enumeration.Version
import com.github.shynixn.blockball.api.business.service.ItemTypeService
import com.github.shynixn.blockball.api.persistence.entity.Item
import com.github.shynixn.blockball.bukkit.logic.business.extension.findClazz
import com.github.shynixn.blockball.core.logic.business.extension.translateChatColors
import com.github.shynixn.blockball.core.logic.persistence.entity.ItemEntity
+import com.github.shynixn.mcutils.common.Version
import com.google.inject.Inject
import com.mojang.authlib.GameProfile
import com.mojang.authlib.properties.Property
@@ -89,7 +89,8 @@ class ItemTypeServiceImpl @Inject constructor(private val version: Version) : It
)
val real = cls.cast(currentMeta)
val field = real.javaClass.getDeclaredField("profile")
- val newSkinProfile = GameProfile(UUID.randomUUID(), null)
+ val profileUUID = UUID.randomUUID()
+ val newSkinProfile = GameProfile(profileUUID, profileUUID.toString().substring(0, 10))
if (newSkin.contains("textures.minecraft.net")) {
if (!newSkin.startsWith("http://")) {
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/PacketJavaProtocolServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/PacketJavaProtocolServiceImpl.kt
deleted file mode 100644
index 3dfd5dc0c..000000000
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/PacketJavaProtocolServiceImpl.kt
+++ /dev/null
@@ -1,188 +0,0 @@
-package com.github.shynixn.blockball.bukkit.logic.business.service
-
-import com.github.shynixn.blockball.api.business.enumeration.CompatibilityArmorSlotType
-import com.github.shynixn.blockball.api.business.enumeration.Version
-import com.github.shynixn.blockball.api.business.proxy.PluginProxy
-import com.github.shynixn.blockball.api.business.service.InternalVersionPacketService
-import com.github.shynixn.blockball.api.business.service.PacketService
-import com.github.shynixn.blockball.api.business.service.ProxyService
-import com.github.shynixn.blockball.api.persistence.entity.EntityMetaData
-import com.github.shynixn.blockball.api.persistence.entity.Position
-import com.github.shynixn.blockball.bukkit.logic.business.extension.findClazz
-import com.google.inject.Inject
-import io.netty.buffer.ByteBuf
-import io.netty.buffer.Unpooled
-
-class PacketJavaProtocolServiceImpl @Inject constructor(
- private val internalVersionPacketService: InternalVersionPacketService,
- private val proxyService: ProxyService,
- private val pluginProxy: PluginProxy
-) :
- PacketService {
- private val dataSerializerClazz by lazy {
- try {
- pluginProxy.findClazz("net.minecraft.network.PacketDataSerializer")
- } catch (e: Exception) {
- pluginProxy.findClazz("net.minecraft.server.VERSION.PacketDataSerializer")
- }
- }
- private val dataSerializerConstructor by lazy { dataSerializerClazz.getDeclaredConstructor(ByteBuf::class.java) }
- private val dataDeSerializationPacketMethod by lazy {
- try {
- pluginProxy.findClazz("net.minecraft.network.protocol.Packet")
- .getDeclaredMethod("a", dataSerializerClazz)
- } catch (e: Exception) {
- pluginProxy.findClazz("net.minecraft.server.VERSION.Packet")
- .getDeclaredMethod("a", dataSerializerClazz)
- }
- }
- private val packetPlayOutEntityDestroyClazz by lazy {
- try {
- pluginProxy.findClazz("net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy")
- } catch (e: Exception) {
- pluginProxy.findClazz("net.minecraft.server.VERSION.PacketPlayOutEntityDestroy")
- }
- }
- private val packetPlayOutEntityVelocity by lazy {
- try {
- pluginProxy.findClazz("net.minecraft.network.protocol.game.PacketPlayOutEntityVelocity")
- } catch (e: Exception) {
- pluginProxy.findClazz("net.minecraft.server.VERSION.PacketPlayOutEntityVelocity")
- }
- }
- private val intArrayListConstructor by lazy {
- try {
- // Paper Spigot shades a different IntList
- pluginProxy.findClazz("org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.IntArrayList")
- .getDeclaredConstructor(IntArray::class.java)
- } catch (e: Exception) {
- pluginProxy.findClazz("it.unimi.dsi.fastutil.ints.IntArrayList")
- .getDeclaredConstructor(IntArray::class.java)
- }
- }
- private val packetPlayOutEntityDestroyIntListConstructor by lazy {
- try {
- // Paper Spigot shades a different IntList
- packetPlayOutEntityDestroyClazz.getDeclaredConstructor(pluginProxy.findClazz("org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.IntList"))
- } catch (e: Exception) {
- packetPlayOutEntityDestroyClazz.getDeclaredConstructor(pluginProxy.findClazz("it.unimi.dsi.fastutil.ints.IntList"))
- }
- }
-
- /**
- * Sends a velocity packet.
- */
- override fun sendEntityVelocityPacket(player: P, entityId: Int, velocity: Position) {
- if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_17_R1)) {
- val packet = packetPlayOutEntityVelocity.getDeclaredConstructor(
- Int::class.java,
- findClazz("net.minecraft.world.phys.Vec3D")
- )
- .newInstance(
- entityId, findClazz("net.minecraft.world.phys.Vec3D")
- .getDeclaredConstructor(Double::class.java, Double::class.java, Double::class.java)
- .newInstance(velocity.x, velocity.y, velocity.z)
- )
- proxyService.sendPacket(player, packet)
- } else {
- val buffer = Unpooled.buffer()
- writeId(buffer, entityId)
- buffer.writeShort((mathhelperA(velocity.x, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(velocity.y, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(velocity.z, -3.9, 3.9) * 8000.0).toInt())
- sendPacket(player, packetPlayOutEntityVelocity, buffer)
- }
- }
-
- /**
- * Sends a destroy packet.
- */
- override fun
sendEntityDestroyPacket(player: P, entityId: Int) {
- val buffer = Unpooled.buffer()
-
- if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_17_R1)) {
- val packet = try {
- val intList = intArrayListConstructor.newInstance(intArrayOf(entityId))
- packetPlayOutEntityDestroyIntListConstructor.newInstance(intList)
- } catch (e: Exception) {
- throw RuntimeException("BlockBall does not support 1.17.0. Upgrade to 1.17.1.!", e)
- }
-
- proxyService.sendPacket(player, packet)
- } else {
- writeId(buffer, 1)
- writeId(buffer, entityId)
- sendPacket(player, packetPlayOutEntityDestroyClazz, buffer)
- }
- }
-
- /**
- * Sends a teleport packet.
- */
- override fun
sendEntityTeleportPacket(player: P, entityId: Int, position: Position) {
- val packet = internalVersionPacketService.createEntityTeleportPacket(entityId, position)
- proxyService.sendPacket(player, packet)
- }
-
- /**
- * Sends a spawn packet.
- */
- override fun
sendEntitySpawnPacket(player: P, entityId: Int, entityType: String, position: Position) {
- val packet = internalVersionPacketService.createEntitySpawnPacket(entityId, entityType, position)
- proxyService.sendPacket(player, packet)
- }
-
- /**
- * Sends a meta data packet.
- */
- override fun
sendEntityMetaDataPacket(player: P, entityId: Int, entityMetaData: EntityMetaData) {
- val packet = internalVersionPacketService.createEntityMetaDataPacket(entityId, entityMetaData)
- proxyService.sendPacket(player, packet)
- }
-
- /**
- * Sends an equipment packet.
- */
- override fun
sendEntityEquipmentPacket(
- player: P,
- entityId: Int,
- slot: CompatibilityArmorSlotType,
- itemStack: I
- ) {
- val packet = internalVersionPacketService.createEntityEquipmentPacket(entityId, slot, itemStack)
- proxyService.sendPacket(player, packet)
- }
-
- /**
- * Sends a packet.
- */
- private fun
sendPacket(player: P, packetClazz: Class<*>, byteBuf: ByteBuf) {
- val packet = packetClazz.newInstance()
- val dataSerializer = dataSerializerConstructor.newInstance(byteBuf)
- dataDeSerializationPacketMethod.invoke(packet, dataSerializer)
- proxyService.sendPacket(player, packet)
- }
-
- /**
- * Writes id bytes.
- */
- private fun writeId(byteBuf: ByteBuf, id: Int) {
- var i = id
- while (i and -128 != 0) {
- byteBuf.writeByte(i and 127 or 128)
- i = i ushr 7
- }
- byteBuf.writeByte(i)
- }
-
- /**
- * Mathhelper
- */
- private fun mathhelperA(var0: Double, var2: Double, var4: Double): Double {
- return if (var0 < var2) {
- var2
- } else {
- if (var0 > var4) var4 else var0
- }
- }
-}
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/ProtocolServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/ProtocolServiceImpl.kt
deleted file mode 100644
index 9faa98d64..000000000
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/ProtocolServiceImpl.kt
+++ /dev/null
@@ -1,179 +0,0 @@
-package com.github.shynixn.blockball.bukkit.logic.business.service
-
-import com.github.shynixn.blockball.api.bukkit.event.PacketEvent
-import com.github.shynixn.blockball.api.business.proxy.PluginProxy
-import com.github.shynixn.blockball.api.business.service.ProtocolService
-import com.github.shynixn.blockball.core.logic.business.extension.accessible
-import com.google.inject.Inject
-import io.netty.channel.Channel
-import io.netty.channel.ChannelDuplexHandler
-import io.netty.channel.ChannelHandlerContext
-import org.bukkit.Bukkit
-import org.bukkit.entity.Player
-import org.bukkit.plugin.Plugin
-import java.util.*
-import java.util.logging.Level
-
-class ProtocolServiceImpl @Inject constructor(private val plugin: PluginProxy, private val internalPlugin: Plugin) :
- ProtocolService {
- private val handlerName = "BlockBall" + "-" + UUID.randomUUID().toString()
- private val playerToNmsPlayer by lazy {
- plugin.findClazz("org.bukkit.craftbukkit.VERSION.entity.CraftPlayer")
- .getDeclaredMethod("getHandle")
- }
- private val playerConnectionField by lazy {
- try {
- plugin.findClazz("net.minecraft.server.level.EntityPlayer")
- .declaredFields.first { e -> e.type.name == "net.minecraft.server.network.PlayerConnection" }
- .accessible(true)
- } catch (ex: Exception) {
- plugin.findClazz("net.minecraft.server.VERSION.EntityPlayer")
- .declaredFields.first { e ->
- e.type.name == "net.minecraft.server.VERSION.PlayerConnection".replace(
- "VERSION",
- plugin.getServerVersion().bukkitId
- )
- }.accessible(true)
- }
- }
- private val networkManagerField by lazy {
- try {
- plugin.findClazz("net.minecraft.server.network.PlayerConnection")
- .declaredFields.first { e -> e.type.name == "net.minecraft.network.NetworkManager" }.accessible(true)
- } catch (ex: Exception) {
- plugin.findClazz("net.minecraft.server.VERSION.PlayerConnection")
- .declaredFields.first { e ->
- e.type.name == "net.minecraft.server.VERSION.NetworkManager".replace(
- "VERSION",
- plugin.getServerVersion().bukkitId
- )
- }.accessible(true)
- }
- }
- private val channelField by lazy {
- try {
- plugin.findClazz("net.minecraft.network.NetworkManager")
- .declaredFields.first { e -> e.type.name == Channel::class.java.name }.accessible(true)
- } catch (ex: Exception) {
- plugin.findClazz("net.minecraft.server.VERSION.NetworkManager")
- .declaredFields.first { e ->
- e.type.name == Channel::class.java.name
- }.accessible(true)
- }
- }
-
- private val cachedPlayerChannels = HashMap()
- private val registeredPackets = HashSet>()
-
- /**
- * Registers the following packets classes for events.
- */
- override fun registerPackets(packets: List>) {
- registeredPackets.addAll(packets)
- }
-
- /**
- * Registers the player.
- */
- override fun register(player: P) {
- require(player is Player)
-
- if (cachedPlayerChannels.containsKey(player)) {
- return
- }
-
- val nmsPlayer = playerToNmsPlayer
- .invoke(player)
- val connection = playerConnectionField
- .get(nmsPlayer)
- val netWorkManager = networkManagerField.get(connection)
- val channel = channelField
- .get(netWorkManager) as Channel
-
- val internalInterceptor = PacketInterceptor(player, this)
- try {
- channel.pipeline().addBefore("packet_handler", handlerName, internalInterceptor)
- } catch (e: NoSuchElementException) {
- channel.pipeline().addFirst(handlerName, internalInterceptor)
- }
- cachedPlayerChannels[player] = channel
- }
-
- /**
- * Clears the player cache.
- */
- override fun
unRegister(player: P) {
- require(player is Player)
-
- if (!cachedPlayerChannels.containsKey(player)) {
- return
- }
-
- val channel = cachedPlayerChannels[player]
- channel!!.eventLoop().execute {
- try {
- channel.pipeline().remove(handlerName)
- } catch (e: Exception) {
- // Ignored
- }
- }
- cachedPlayerChannels.remove(player)
- }
-
- /**
- * Disposes the protocol service.
- */
- override fun dispose() {
- for (player in cachedPlayerChannels.keys.toTypedArray()) {
- unRegister(player)
- }
-
- registeredPackets.clear()
- }
-
- /**
- * On Message receive.
- */
- private fun onMessageReceive(player: Player, packet: Any): Boolean {
- if (!plugin.isEnabled()) {
- return false
- }
-
- if (cachedPlayerChannels.isEmpty()) {
- return false
- }
-
- if (!this.registeredPackets.contains(packet.javaClass)) {
- return false
- }
-
- internalPlugin.server.scheduler.runTask(internalPlugin, Runnable {
- val packetEvent = PacketEvent(player, packet)
- Bukkit.getPluginManager().callEvent(packetEvent)
- })
-
- return false
- }
-
- private class PacketInterceptor(
- private val player: Player,
- private val protocolServiceImpl: ProtocolServiceImpl
- ) :
- ChannelDuplexHandler() {
- /**
- * Incoming packet.
- */
- override fun channelRead(ctx: ChannelHandlerContext, msg: Any) {
- val cancelled = try {
- protocolServiceImpl.onMessageReceive(player, msg)
- } catch (e: Exception) {
- Bukkit.getServer().logger.log(Level.SEVERE, "Failed to read packet.", e)
- false
- }
-
- if (!cancelled) {
- super.channelRead(ctx, msg)
- }
- }
- }
-}
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/ProxyServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/ProxyServiceImpl.kt
index 7e8c47338..f641bb5a8 100644
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/ProxyServiceImpl.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/ProxyServiceImpl.kt
@@ -2,18 +2,19 @@
package com.github.shynixn.blockball.bukkit.logic.business.service
-import com.github.shynixn.blockball.api.business.enumeration.Version
import com.github.shynixn.blockball.api.business.proxy.PluginProxy
import com.github.shynixn.blockball.api.business.service.ItemTypeService
import com.github.shynixn.blockball.api.business.service.ProxyService
import com.github.shynixn.blockball.api.persistence.entity.ChatBuilder
import com.github.shynixn.blockball.api.persistence.entity.Item
import com.github.shynixn.blockball.api.persistence.entity.Position
-import com.github.shynixn.blockball.bukkit.logic.business.extension.findClazz
+import com.github.shynixn.blockball.bukkit.logic.business.extension.*
import com.github.shynixn.blockball.bukkit.logic.business.extension.toLocation
import com.github.shynixn.blockball.bukkit.logic.business.extension.toPosition
import com.github.shynixn.blockball.bukkit.logic.business.extension.toVector
-import com.github.shynixn.blockball.core.logic.business.extension.accessible
+import com.github.shynixn.mcutils.common.Version
+import com.github.shynixn.mcutils.packet.api.EntityService
+import com.github.shynixn.mcutils.packet.api.PacketService
import com.google.inject.Inject
import org.bukkit.Bukkit
import org.bukkit.GameMode
@@ -28,16 +29,16 @@ import org.bukkit.plugin.Plugin
import org.bukkit.scoreboard.Scoreboard
import org.bukkit.util.Vector
import java.util.*
-import java.util.concurrent.atomic.AtomicInteger
import java.util.logging.Level
import java.util.stream.Stream
import kotlin.streams.asStream
class ProxyServiceImpl @Inject constructor(
private val pluginProxy: PluginProxy,
- private val itemTypeService: ItemTypeService
+ private val itemTypeService: ItemTypeService,
+ private val entityService: EntityService,
+ private val packetService : PacketService
) : ProxyService {
-
/**
* Gets the name of the World the player is in.
*/
@@ -518,7 +519,7 @@ class ProxyServiceImpl @Inject constructor(
}
try {
- val packet = if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_19_R1)) {
+ val packet = if (pluginProxy.getCompatibilityServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_19_R1)) {
val clazz = Class.forName("net.minecraft.network.chat.IChatBaseComponent\$ChatSerializer")
val packetClazz = findClazz("net.minecraft.network.protocol.game.ClientboundSystemChatPacket")
val chatBaseComponentClazz = findClazz("net.minecraft.network.chat.IChatBaseComponent")
@@ -533,7 +534,7 @@ class ProxyServiceImpl @Inject constructor(
packetClazz.getDeclaredConstructor(chatBaseComponentClazz, Int::class.java)
.newInstance(chatComponent, 1)
}
- } else if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_17_R1)) {
+ } else if (pluginProxy.getCompatibilityServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_17_R1)) {
val clazz = Class.forName("net.minecraft.network.chat.IChatBaseComponent\$ChatSerializer")
val packetClazz = findClazz("net.minecraft.network.protocol.game.PacketPlayOutChat")
val chatBaseComponentClazz = findClazz("net.minecraft.network.chat.IChatBaseComponent")
@@ -541,7 +542,7 @@ class ProxyServiceImpl @Inject constructor(
clazz.getDeclaredMethod("a", String::class.java).invoke(null, chatBuilder.toString())
val systemUtilsClazz = findClazz("net.minecraft.SystemUtils")
val defaultUUID =
- if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_18_R2)) {
+ if (pluginProxy.getCompatibilityServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_18_R2)) {
systemUtilsClazz.getDeclaredField("c").get(null) as UUID
} else {
systemUtilsClazz.getDeclaredField("b").get(null) as UUID
@@ -562,14 +563,14 @@ class ProxyServiceImpl @Inject constructor(
clazz.getDeclaredMethod("a", String::class.java).invoke(null, chatBuilder.toString())
when {
- pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_16_R1) -> {
+ pluginProxy.getCompatibilityServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_16_R1) -> {
val systemUtilsClazz = findClazz("net.minecraft.server.VERSION.SystemUtils")
val defaultUUID = systemUtilsClazz.getDeclaredField("b").get(null) as UUID
val chatEnumMessage = findClazz("net.minecraft.server.VERSION.ChatMessageType")
packetClazz.getDeclaredConstructor(chatBaseComponentClazz, chatEnumMessage, UUID::class.java)
.newInstance(chatComponent, chatEnumMessage.enumConstants[0], defaultUUID)
}
- pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_12_R1) -> {
+ pluginProxy.getCompatibilityServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_12_R1) -> {
val chatEnumMessage = findClazz("net.minecraft.server.VERSION.ChatMessageType")
packetClazz.getDeclaredConstructor(chatBaseComponentClazz, chatEnumMessage)
.newInstance(chatComponent, chatEnumMessage.enumConstants[0])
@@ -665,79 +666,14 @@ class ProxyServiceImpl @Inject constructor(
* Creates a new entity id.
*/
override fun createNewEntityId(): Int {
- return if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_19_R3)) {
- val atomicInteger = findClazz("net.minecraft.world.entity.Entity")
- .getDeclaredField("d")
- .accessible(true)
- .get(null) as AtomicInteger
- atomicInteger.incrementAndGet()
- } else if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_18_R2)) {
- val atomicInteger = findClazz("net.minecraft.world.entity.Entity")
- .getDeclaredField("c")
- .accessible(true)
- .get(null) as AtomicInteger
- atomicInteger.incrementAndGet()
- } else if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_17_R1)) {
- val atomicInteger = findClazz("net.minecraft.world.entity.Entity")
- .getDeclaredField("b")
- .accessible(true)
- .get(null) as AtomicInteger
- atomicInteger.incrementAndGet()
- } else if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_14_R1)) {
- val atomicInteger = findClazz("net.minecraft.server.VERSION.Entity")
- .getDeclaredField("entityCount")
- .accessible(true)
- .get(null) as AtomicInteger
- atomicInteger.incrementAndGet()
- } else {
- val entityCountField = findClazz("net.minecraft.server.VERSION.Entity")
- .getDeclaredField("entityCount")
- .accessible(true)
- val intNumber = (entityCountField.get(null) as Int) + 1
- entityCountField.set(null, intNumber)
- intNumber
- }
+ return entityService.createNewEntityId()
}
/**
* Sends the given [packet] to the given [player].
*/
override fun
sendPacket(player: P, packet: Any) {
- val craftPlayerClazz = findClazz("org.bukkit.craftbukkit.VERSION.entity.CraftPlayer")
- val getHandleMethod = craftPlayerClazz.getDeclaredMethod("getHandle")
- val nmsPlayer = getHandleMethod.invoke(player)
-
- if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_17_R1)) {
- val nmsPlayerClazz = findClazz("net.minecraft.server.level.EntityPlayer")
- val playerConnectionField =
- if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_20_R1)) {
- nmsPlayerClazz.getDeclaredField("c")
- } else {
- nmsPlayerClazz.getDeclaredField("b")
- }
- playerConnectionField.isAccessible = true
- val connection = playerConnectionField.get(nmsPlayer)
-
- val playerConnectionClazz = findClazz("net.minecraft.server.network.PlayerConnection")
- val packetClazz = findClazz("net.minecraft.network.protocol.Packet")
-
- if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_18_R1)) {
- val sendPacketMethod = playerConnectionClazz.getDeclaredMethod("a", packetClazz)
- sendPacketMethod.invoke(connection, packet)
- } else {
- val sendPacketMethod = playerConnectionClazz.getDeclaredMethod("sendPacket", packetClazz)
- sendPacketMethod.invoke(connection, packet)
- }
- } else {
- val nmsPlayerClazz = findClazz("net.minecraft.server.VERSION.EntityPlayer")
- val playerConnectionField = nmsPlayerClazz.getDeclaredField("playerConnection")
- playerConnectionField.isAccessible = true
- val connection = playerConnectionField.get(nmsPlayer)
-
- val playerConnectionClazz = findClazz("net.minecraft.server.VERSION.PlayerConnection")
- val packetClazz = findClazz("net.minecraft.server.VERSION.Packet")
- val sendPacketMethod = playerConnectionClazz.getDeclaredMethod("sendPacket", packetClazz)
- sendPacketMethod.invoke(connection, packet)
- }
+ require(player is Player)
+ packetService.sendNativePacket(player, packet)
}
}
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/SoundServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/SoundServiceImpl.kt
index dca912b8b..2b5329308 100644
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/SoundServiceImpl.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/SoundServiceImpl.kt
@@ -2,13 +2,14 @@
package com.github.shynixn.blockball.bukkit.logic.business.service
-import com.github.shynixn.blockball.api.business.enumeration.Version
import com.github.shynixn.blockball.api.business.proxy.PluginProxy
import com.github.shynixn.blockball.api.business.service.ConcurrencyService
import com.github.shynixn.blockball.api.business.service.LoggingService
import com.github.shynixn.blockball.api.business.service.SoundService
import com.github.shynixn.blockball.api.persistence.entity.Sound
+import com.github.shynixn.blockball.bukkit.logic.business.extension.getCompatibilityServerVersion
import com.github.shynixn.blockball.core.logic.business.extension.async
+import com.github.shynixn.mcutils.common.Version
import com.google.inject.Inject
import org.bukkit.Location
import org.bukkit.entity.Player
@@ -84,7 +85,7 @@ class SoundServiceImpl @Inject constructor(
* Converts the given [name].
*/
private fun convertName(name: String): String {
- val version = plugin.getServerVersion()
+ val version = plugin.getCompatibilityServerVersion()
if (version.isVersionSameOrGreaterThan(Version.VERSION_1_13_R1)) {
when (name) {
@@ -172,4 +173,4 @@ class SoundServiceImpl @Inject constructor(
return name
}
-}
\ No newline at end of file
+}
diff --git a/blockball-bukkit-plugin/bukkit-nms-117R1/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_17_R1/ScreenMessage117R1ServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_13_R2/ScreenMessage113R1ServiceImpl.kt
similarity index 93%
rename from blockball-bukkit-plugin/bukkit-nms-117R1/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_17_R1/ScreenMessage117R1ServiceImpl.kt
rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_13_R2/ScreenMessage113R1ServiceImpl.kt
index 6f35a214a..3ec69c9b9 100644
--- a/blockball-bukkit-plugin/bukkit-nms-117R1/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_17_R1/ScreenMessage117R1ServiceImpl.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_13_R2/ScreenMessage113R1ServiceImpl.kt
@@ -1,4 +1,4 @@
-package com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_17_R1
+package com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_13_R2
import com.github.shynixn.blockball.api.business.service.ScreenMessageService
import com.github.shynixn.blockball.core.logic.business.extension.translateChatColors
@@ -6,7 +6,7 @@ import net.md_5.bungee.api.ChatMessageType
import net.md_5.bungee.api.chat.TextComponent
import org.bukkit.entity.Player
-class ScreenMessage117R1ServiceImpl : ScreenMessageService {
+class ScreenMessage113R1ServiceImpl : ScreenMessageService {
/**
* Sets the [title] of the given [player] [P] for the amount of [stay] ticks. Optionally shows a [subTitle] and displays
* a [fadeIn] and [fadeOut] effect in ticks.
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_8_R3/InternalVersionPacket18R3ServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_8_R3/InternalVersionPacket18R3ServiceImpl.kt
deleted file mode 100644
index e432dac5a..000000000
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_8_R3/InternalVersionPacket18R3ServiceImpl.kt
+++ /dev/null
@@ -1,227 +0,0 @@
-package com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_8_R3
-
-import com.github.shynixn.blockball.api.business.enumeration.CompatibilityArmorSlotType
-import com.github.shynixn.blockball.api.business.proxy.PluginProxy
-import com.github.shynixn.blockball.api.business.service.InternalVersionPacketService
-import com.github.shynixn.blockball.api.persistence.entity.EntityMetaData
-import com.github.shynixn.blockball.api.persistence.entity.Position
-import com.github.shynixn.blockball.core.logic.business.extension.accessible
-import com.google.inject.Inject
-import io.netty.buffer.ByteBuf
-import io.netty.buffer.Unpooled
-import kotlin.math.floor
-
-class InternalVersionPacket18R3ServiceImpl @Inject constructor(private val pluginProxy: PluginProxy) :
- InternalVersionPacketService {
- private val entityCompatibilityCache = hashMapOf("ARMOR_STAND" to 30, "SLIME" to 55)
- private val dataSerializerClazz by lazy { pluginProxy.findClazz("net.minecraft.server.VERSION.PacketDataSerializer") }
- private val dataSerializerConstructor by lazy { dataSerializerClazz.getDeclaredConstructor(ByteBuf::class.java) }
- private val dataDeSerializationPacketMethod by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.Packet")
- .getDeclaredMethod("a", dataSerializerClazz)
- }
- private val packetPlayOutEntityTeleport by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.PacketPlayOutEntityTeleport")
- }
- private val dataWatcherClazz by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.DataWatcher")
- }
- private val dataWatcherConstructor by lazy {
- dataWatcherClazz.getDeclaredConstructor(pluginProxy.findClazz("net.minecraft.server.VERSION.Entity"))
- }
- private val packetPlayOutEntitySpawnLiving by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.PacketPlayOutSpawnEntityLiving")
- }
- private val vector3fClazz by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.Vector3f")
- }
- private val packetPlayOutEntityMetaData by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.PacketPlayOutEntityMetadata")
- }
- private val craftItemStackNmsMethod by lazy {
- pluginProxy.findClazz("org.bukkit.craftbukkit.VERSION.inventory.CraftItemStack")
- .getDeclaredMethod("asNMSCopy", pluginProxy.findClazz("org.bukkit.inventory.ItemStack"))
- }
- private val nmsItemStackClazz by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.ItemStack")
- }
-
- companion object {
-
- }
-
- private val packetPlayOutEntityEquipment by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.PacketPlayOutEntityEquipment")
- }
-
- /**
- * Creates a new teleport packet.
- */
- override fun createEntityTeleportPacket(entityId: Int, position: Position): Any {
- val buffer = Unpooled.buffer()
- buffer.writeId(entityId)
- buffer.writeInt(floor(position.x * 32.0).toInt())
- buffer.writeInt(floor(position.y * 32.0).toInt())
- buffer.writeInt(floor(position.z * 32.0).toInt())
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeBoolean(false)
- return createPacketFromBuffer(packetPlayOutEntityTeleport, buffer)
- }
-
- /**
- * Creates a spawn packet.
- */
- override fun createEntitySpawnPacket(entityId: Int, entityType: String, position: Position): Any {
- val buffer = Unpooled.buffer()
- buffer.writeId(entityId)
-
- buffer.writeByte(entityCompatibilityCache[entityType]!! and 255)
- buffer.writeInt(floor(position.x * 32.0).toInt())
- buffer.writeInt(floor(position.y * 32.0).toInt())
- buffer.writeInt(floor(position.z * 32.0).toInt())
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte(0)
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
-
- buffer.writeByte(127)
- val packet = packetPlayOutEntitySpawnLiving.getDeclaredConstructor().newInstance()
- val dataSerializer = dataSerializerConstructor.newInstance(buffer)
- dataDeSerializationPacketMethod.invoke(packet, dataSerializer)
- packetPlayOutEntitySpawnLiving.getDeclaredField("l")
- .accessible(true).set(packet, dataWatcherConstructor.newInstance(null))
- return packet
- }
-
- /**
- * Creates a entity metadata packet.
- */
- override fun createEntityMetaDataPacket(entityId: Int, entityMetaData: EntityMetaData): Any {
- // https://wiki.vg/index.php?title=Entity_metadata&oldid=6611 -> Value of Type field. Type of Value = Boolean -> 7.
- val dataWatcher = WrappedDataWatcher18R1(pluginProxy)
-
- if (entityMetaData.customNameVisible != null) {
- dataWatcher.set(3, boolToInt(entityMetaData.customNameVisible!!).toByte())
- }
-
- if (entityMetaData.customname != null) {
- dataWatcher.set(2, entityMetaData.customname)
- }
-
- if (entityMetaData.isInvisible != null) {
- if (entityMetaData.isInvisible!!) {
- dataWatcher.set(0, (0 or (1 shl 5)).toByte())
- } else {
- dataWatcher.set(0, (0 and (1 shl 5)).toByte())
- }
- }
-
- if (entityMetaData.slimeSize != null) {
- dataWatcher.set(16, entityMetaData.slimeSize!!.toByte())
- }
-
- if (entityMetaData.armorstandHeadRotation != null) {
- val vector3f = vector3fClazz.getDeclaredConstructor(Float::class.java, Float::class.java, Float::class.java)
- .newInstance(
- entityMetaData.armorstandHeadRotation!!.x.toFloat(),
- entityMetaData.armorstandHeadRotation!!.y.toFloat(),
- entityMetaData.armorstandHeadRotation!!.z.toFloat()
- )
- dataWatcher.set(11, vector3f)
- }
-
- if (entityMetaData.isSmall != null && entityMetaData.isSmall!!) {
- dataWatcher.set(10, 1.toByte())
- }
-
- val packet = packetPlayOutEntityMetaData.getDeclaredConstructor(
- Int::class.java,
- pluginProxy.findClazz("net.minecraft.server.VERSION.DataWatcher"),
- Boolean::class.java
- ).newInstance(entityId, dataWatcher.getHandle(), true)
- return packet
- }
-
- /**
- * Creates an entity equipment packet.
- */
- override fun createEntityEquipmentPacket(entityId: Int, slot: CompatibilityArmorSlotType, itemStack: I): Any {
- val nmsItemStack = craftItemStackNmsMethod.invoke(null, itemStack)
- return packetPlayOutEntityEquipment
- .getDeclaredConstructor(Int::class.java, Int::class.java, nmsItemStackClazz)
- .newInstance(entityId, slot.id18, nmsItemStack)
- }
-
- /**
- * Creates a packet from buffer.
- */
- private fun createPacketFromBuffer(packetClazz: Class<*>, byteBuf: ByteBuf): Any {
- val packet = packetClazz.getDeclaredConstructor().newInstance()
- val dataSerializer = dataSerializerConstructor.newInstance(byteBuf)
- dataDeSerializationPacketMethod.invoke(packet, dataSerializer)
- return packet
- }
-
- /**
- * Writes id.
- */
- private fun ByteBuf.writeId(id: Int) {
- var i = id
- while (i and -128 != 0) {
- writeByte(i and 127 or 128)
- i = i ushr 7
- }
- writeByte(i)
- }
-
- /**
- * Mathhelper
- */
- private fun mathhelperA(var0: Double, var2: Double, var4: Double): Double {
- return if (var0 < var2) {
- var2
- } else {
- if (var0 > var4) var4 else var0
- }
- }
-
- /**
- * Bool to int helper.
- */
- private fun boolToInt(boolean: Boolean): Int {
- if (boolean) {
- return 1
- }
- return 0
- }
-
- class WrappedDataWatcher18R1(private val pluginProxy: PluginProxy) {
- private val dataWatcherClazz by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.DataWatcher")
- }
- private val dataWatcherConstructor by lazy {
- dataWatcherClazz.getDeclaredConstructor(pluginProxy.findClazz("net.minecraft.server.VERSION.Entity"))
- }
- private val dataWatcher = dataWatcherConstructor.newInstance(null)
- private val dataWatcherMethod by lazy {
- dataWatcherClazz.getDeclaredMethod("a", Int::class.java, Any::class.java)
- }
-
- /**
- * Sets the value at the given index.
- */
- fun set(index: Int, value: T) {
- dataWatcherMethod.invoke(dataWatcher, index, value)
- }
-
- /**
- * Gets the nms handle.
- */
- fun getHandle(): Any {
- return dataWatcher
- }
- }
-}
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_8_R3/Particle18R3ServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_8_R3/Particle18R3ServiceImpl.kt
index a7eba86d7..6ecc18bae 100644
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_8_R3/Particle18R3ServiceImpl.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_8_R3/Particle18R3ServiceImpl.kt
@@ -3,12 +3,12 @@
package com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_8_R3
import com.github.shynixn.blockball.api.business.enumeration.ParticleType
-import com.github.shynixn.blockball.api.business.enumeration.Version
import com.github.shynixn.blockball.api.business.service.LoggingService
import com.github.shynixn.blockball.api.business.service.ParticleService
import com.github.shynixn.blockball.api.business.service.ProxyService
import com.github.shynixn.blockball.api.persistence.entity.Particle
import com.github.shynixn.blockball.api.persistence.entity.Position
+import com.github.shynixn.mcutils.common.Version
import com.google.inject.Inject
import org.bukkit.Bukkit
import org.bukkit.Location
@@ -196,13 +196,6 @@ class Particle18R3ServiceImpl @Inject constructor(
}
}
- /**
- * Finds the version dependent class.
- */
- private fun findClazz(name: String): Class<*> {
- return Class.forName(name.replace("VERSION", version.bukkitId))
- }
-
private fun isLongDistance(location: Location, players: Array): Boolean {
return players.any { location.world!!.name == it.location.world!!.name && it.location.distanceSquared(location) > 65536 }
}
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_8_R3/RayTracingService18R3Impl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_8_R3/RayTracingService18R3Impl.kt
index 988769cf1..79e220c4c 100644
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_8_R3/RayTracingService18R3Impl.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_8_R3/RayTracingService18R3Impl.kt
@@ -2,14 +2,15 @@ package com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_8_R3
import com.github.shynixn.blockball.api.BlockBallApi
import com.github.shynixn.blockball.api.business.enumeration.BlockDirection
-import com.github.shynixn.blockball.api.business.enumeration.Version
import com.github.shynixn.blockball.api.business.proxy.PluginProxy
import com.github.shynixn.blockball.api.business.service.RayTracingService
import com.github.shynixn.blockball.api.persistence.entity.Position
import com.github.shynixn.blockball.api.persistence.entity.RaytraceResult
+import com.github.shynixn.blockball.bukkit.logic.business.extension.getCompatibilityServerVersion
import com.github.shynixn.blockball.core.logic.business.extension.accessible
import com.github.shynixn.blockball.core.logic.persistence.entity.PositionEntity
import com.github.shynixn.blockball.core.logic.persistence.entity.RayTraceResultEntity
+import com.github.shynixn.mcutils.common.Version
import com.google.inject.Inject
import org.bukkit.Bukkit
@@ -61,7 +62,7 @@ class RayTracingService18R3Impl @Inject constructor(private val pluginProxy: Plu
val resultVector = movingObjectClazz.getDeclaredField("pos").accessible(true).get(movingObjectPosition)
- val resultPosition = if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_9_R1)) {
+ val resultPosition = if (pluginProxy.getCompatibilityServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_9_R1)) {
PositionEntity(
position.worldName!!,
vector3dClazz.getDeclaredField("x").get(resultVector) as Double,
@@ -96,7 +97,7 @@ class RayTracingService18R3Impl @Inject constructor(private val pluginProxy: Plu
return Class.forName(
name.replace(
"VERSION",
- BlockBallApi.resolve(PluginProxy::class.java).getServerVersion().bukkitId
+ BlockBallApi.resolve(PluginProxy::class.java).getCompatibilityServerVersion().bukkitId
)
)
}
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_8_R3/ScreenMessage18R3ServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_8_R3/ScreenMessage18R3ServiceImpl.kt
index 9c59516f7..f57deeaaa 100644
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_8_R3/ScreenMessage18R3ServiceImpl.kt
+++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_8_R3/ScreenMessage18R3ServiceImpl.kt
@@ -1,11 +1,12 @@
package com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_8_R3
-import com.github.shynixn.blockball.api.business.enumeration.Version
import com.github.shynixn.blockball.api.business.proxy.PluginProxy
import com.github.shynixn.blockball.api.business.service.ProxyService
import com.github.shynixn.blockball.api.business.service.ScreenMessageService
import com.github.shynixn.blockball.core.logic.business.extension.translateChatColors
import com.github.shynixn.blockball.bukkit.logic.business.extension.findClazz
+import com.github.shynixn.blockball.bukkit.logic.business.extension.getCompatibilityServerVersion
+import com.github.shynixn.mcutils.common.Version
import com.google.inject.Inject
import org.bukkit.entity.Player
import java.util.*
@@ -52,7 +53,7 @@ class ScreenMessage18R3ServiceImpl @Inject constructor(
val finalTitle = title.translateChatColors()
val finalSubTitle = subTitle.translateChatColors()
- val version = plugin.getServerVersion()
+ val version = plugin.getCompatibilityServerVersion()
val serializerMethod =
if (version.isVersionSameOrGreaterThan(Version.VERSION_1_8_R2)) {
@@ -121,7 +122,7 @@ class ScreenMessage18R3ServiceImpl @Inject constructor(
}
val finalMessage = message.translateChatColors()
- val version = plugin.getServerVersion()
+ val version = plugin.getCompatibilityServerVersion()
val chatBaseComponentClazz = findClazz("net.minecraft.server.VERSION.IChatBaseComponent")
val packetClazz = findClazz("net.minecraft.server.VERSION.PacketPlayOutChat")
diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_9_R2/InternalVersionPacket19R2ServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_9_R2/InternalVersionPacket19R2ServiceImpl.kt
deleted file mode 100644
index 455f5ef34..000000000
--- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/bukkit/logic/business/service/nms/v1_9_R2/InternalVersionPacket19R2ServiceImpl.kt
+++ /dev/null
@@ -1,307 +0,0 @@
-package com.github.shynixn.blockball.bukkit.logic.business.service.nms.v1_9_R2
-
-import com.github.shynixn.blockball.api.business.enumeration.CompatibilityArmorSlotType
-import com.github.shynixn.blockball.api.business.enumeration.Version
-import com.github.shynixn.blockball.api.business.proxy.PluginProxy
-import com.github.shynixn.blockball.api.business.service.InternalVersionPacketService
-import com.github.shynixn.blockball.api.business.service.LoggingService
-import com.github.shynixn.blockball.api.persistence.entity.EntityMetaData
-import com.github.shynixn.blockball.api.persistence.entity.Position
-import com.github.shynixn.blockball.bukkit.logic.business.extension.findClazz
-import com.github.shynixn.blockball.core.logic.business.extension.accessible
-import com.google.inject.Inject
-import com.mojang.authlib.GameProfile
-import io.netty.buffer.ByteBuf
-import io.netty.buffer.Unpooled
-import org.bukkit.inventory.ItemStack
-import java.nio.charset.Charset
-import java.util.*
-
-class InternalVersionPacket19R2ServiceImpl @Inject constructor(
- private val pluginProxy: PluginProxy,
- private val loggingService: LoggingService
-) :
- InternalVersionPacketService {
- private val entityCompatibilityCache = hashMapOf("ARMOR_STAND" to 30, "SLIME" to 55)
- private val dataSerializerClazz by lazy { pluginProxy.findClazz("net.minecraft.server.VERSION.PacketDataSerializer") }
- private val dataSerializerConstructor by lazy { dataSerializerClazz.getDeclaredConstructor(ByteBuf::class.java) }
- private val dataDeSerializationPacketMethod by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.Packet")
- .getDeclaredMethod("a", dataSerializerClazz)
- }
- private val packetPlayOutEntityTeleport by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.PacketPlayOutEntityTeleport")
- }
- private val packetPlayOutEntitySpawnLiving by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.PacketPlayOutSpawnEntityLiving")
- }
- private val dataWatcherClazz by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.DataWatcher")
- }
- private val dataWatcherConstructor by lazy {
- dataWatcherClazz.getDeclaredConstructor(pluginProxy.findClazz("net.minecraft.server.VERSION.Entity"))
- }
- private val packetPlayOutEntityMetaData by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.PacketPlayOutEntityMetadata")
- }
- private val craftItemStackNmsMethod by lazy {
- pluginProxy.findClazz("org.bukkit.craftbukkit.VERSION.inventory.CraftItemStack")
- .getDeclaredMethod("asNMSCopy", pluginProxy.findClazz("org.bukkit.inventory.ItemStack"))
- }
- private val nmsItemStackClazz by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.ItemStack")
- }
- private val packetPlayOutEntityEquipment by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.PacketPlayOutEntityEquipment")
- }
- private val enumItemSlotClazz by lazy {
- pluginProxy.findClazz("net.minecraft.server.VERSION.EnumItemSlot")
- }
- private val iRegistryClazz by lazy { pluginProxy.findClazz("net.minecraft.server.VERSION.IRegistry") }
- private val entityRegistry by lazy { iRegistryClazz.getDeclaredField("ENTITY_TYPE").get(null) }
- private val iRegistryRegisterMethod by lazy { iRegistryClazz.getDeclaredMethod("a", Any::class.java) }
- private val entityTypesClazz by lazy { pluginProxy.findClazz("net.minecraft.server.VERSION.EntityTypes") }
- private val mojangPairClazz by lazy {
- pluginProxy.findClazz("com.mojang.datafixers.util.Pair")
- }
-
- /**
- * Creates a new teleport packet.
- */
- override fun createEntityTeleportPacket(entityId: Int, position: Position): Any {
- val buffer = Unpooled.buffer()
- buffer.writeId(entityId)
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeBoolean(false)
- return createPacketFromBuffer(packetPlayOutEntityTeleport, buffer)
- }
-
- /**
- * Creates a spawn packet.
- */
- override fun createEntitySpawnPacket(entityId: Int, entityType: String, position: Position): Any {
- val buffer = Unpooled.buffer()
- buffer.writeId(entityId)
-
- val entityUUID = UUID.randomUUID()
- buffer.writeLong(entityUUID.mostSignificantBits)
- buffer.writeLong(entityUUID.leastSignificantBits)
-
- when {
- pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_13_R1) -> {
- val nmsEntityType = entityTypesClazz.getDeclaredField(entityType).get(null)
- val nmsEntityId = iRegistryRegisterMethod.invoke(entityRegistry, nmsEntityType) as Int
- buffer.writeId(nmsEntityId)
- }
- pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_11_R1) -> {
- buffer.writeId(entityCompatibilityCache[entityType]!!)
- }
- else -> {
- buffer.writeByte(entityCompatibilityCache[entityType]!! and 255)
- }
- }
-
- buffer.writeDouble(position.x)
- buffer.writeDouble(position.y)
- buffer.writeDouble(position.z)
- buffer.writeByte((position.yaw * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte((position.pitch * 256.0f / 360.0f).toInt().toByte().toInt())
- buffer.writeByte(0)
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
- buffer.writeShort((mathhelperA(0.0, -3.9, 3.9) * 8000.0).toInt())
-
- if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_15_R1)) {
- return createPacketFromBuffer(packetPlayOutEntitySpawnLiving, buffer)
- }
-
- buffer.writeByte(255)
- val packet = packetPlayOutEntitySpawnLiving.getDeclaredConstructor().newInstance()
- val dataSerializer = dataSerializerConstructor.newInstance(buffer)
- dataDeSerializationPacketMethod.invoke(packet, dataSerializer)
- packetPlayOutEntitySpawnLiving.getDeclaredField("m")
- .accessible(true).set(packet, dataWatcherConstructor.newInstance(null))
- return packet
- }
-
- /**
- * Creates a entity metadata packet.
- */
- override fun createEntityMetaDataPacket(entityId: Int, entityMetaData: EntityMetaData): Any {
- // https://wiki.vg/Entity_metadata#Entity_Metadata_Format -> Value of Type field. Type of Value = Boolean -> 7.
- // 1.9.4 -> https://wiki.vg/index.php?title=Entity_metadata&oldid=7864
- val buffer = Unpooled.buffer()
- buffer.writeId(entityId)
-
- val byteTypeValue = 0
- val intTypeValue = 1
-
- val booleanTypeValue = if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_13_R1)) {
- 7
- } else {
- 6
- }
-
- val optChatTypeValue = 5
-
- val rotationTypeValue =
- if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_13_R1)) {
- 8
- } else {
- 7
- }
-
- if (entityMetaData.customNameVisible != null) {
- buffer.writeByte(3)
- buffer.writeId(booleanTypeValue)
- buffer.writeBoolean(entityMetaData.customNameVisible!!)
- }
-
- if (entityMetaData.customname != null) {
- if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_13_R1)) {
- val payload = "{\"text\": \"${entityMetaData.customname}\"}".toByteArray(Charset.forName("UTF-8"))
- buffer.writeByte(2)
- buffer.writeId(optChatTypeValue)
- buffer.writeBoolean(true)
- buffer.writeId(payload.size)
- buffer.writeBytes(payload)
- } else {
- val stringType = 3
- val payload = entityMetaData.customname!!.toByteArray(Charset.forName("UTF-8"))
- buffer.writeByte(2)
- buffer.writeId(stringType)
- buffer.writeId(payload.size)
- buffer.writeBytes(payload)
- }
- }
-
- if (entityMetaData.slimeSize != null) {
- val slimeSizeIndex =
- when {
- pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_15_R1) -> {
- 15
- }
- pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_10_R1) -> {
- 12
- }
- else -> {
- 11
- }
- }
-
- buffer.writeByte(slimeSizeIndex)
- buffer.writeId(intTypeValue)
- buffer.writeId(entityMetaData.slimeSize!!)
- }
-
- if (entityMetaData.armorstandHeadRotation != null) {
- when {
- pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_15_R1) -> {
- buffer.writeByte(15)
- }
- pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_10_R1) -> {
- buffer.writeByte(12)
- }
- else -> {
- buffer.writeByte(11)
- }
- }
-
- buffer.writeId(rotationTypeValue)
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.x.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.y.toFloat())
- buffer.writeFloat(entityMetaData.armorstandHeadRotation!!.z.toFloat())
- }
-
- if (entityMetaData.isInvisible != null) {
- buffer.writeByte(0)
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x20)
- }
-
- if (entityMetaData.isSmall != null && entityMetaData.isSmall!!) {
- when {
- pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_15_R1) -> {
- buffer.writeByte(14)
- }
- pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_10_R1) -> {
- buffer.writeByte(11)
- }
- else -> {
- buffer.writeByte(10)
- }
- }
-
- buffer.writeId(byteTypeValue)
- buffer.writeByte(0x01)
- }
-
- buffer.writeByte(255)
-
- return createPacketFromBuffer(packetPlayOutEntityMetaData, buffer)
- }
-
- /**
- * Creates an entity equipment packet.
- */
- override fun createEntityEquipmentPacket(entityId: Int, slot: CompatibilityArmorSlotType, itemStack: I): Any {
- val skullMeta = (itemStack as ItemStack).itemMeta;
- val gameProfile = findClazz("org.bukkit.craftbukkit.VERSION.inventory.CraftMetaSkull")
- .getDeclaredField("profile")
- .accessible(true)
- .get(skullMeta) as GameProfile
-
- val nmsItemStack = craftItemStackNmsMethod.invoke(null, itemStack)
-
- if (pluginProxy.getServerVersion().isVersionSameOrGreaterThan(Version.VERSION_1_16_R1)) {
- val pair = mojangPairClazz.getDeclaredConstructor(Any::class.java, Any::class.java)
- .newInstance(enumItemSlotClazz.enumConstants[slot.id116], nmsItemStack)
- return packetPlayOutEntityEquipment
- .getDeclaredConstructor(Int::class.java, List::class.java)
- .newInstance(entityId, listOf(pair))
- }
-
- return packetPlayOutEntityEquipment
- .getDeclaredConstructor(Int::class.java, enumItemSlotClazz, nmsItemStackClazz)
- .newInstance(entityId, enumItemSlotClazz.enumConstants[slot.id116], nmsItemStack)
- }
-
-
- /*
- * Creates a packet from buffer.
- */
- private fun createPacketFromBuffer(packetClazz: Class<*>, byteBuf: ByteBuf): Any {
- val packet = packetClazz.getDeclaredConstructor().newInstance()
- val dataSerializer = dataSerializerConstructor.newInstance(byteBuf)
- dataDeSerializationPacketMethod.invoke(packet, dataSerializer)
- return packet
- }
-
- /**
- * Writes id.
- */
- private fun ByteBuf.writeId(id: Int) {
- var i = id
- while (i and -128 != 0) {
- writeByte(i and 127 or 128)
- i = i ushr 7
- }
- writeByte(i)
- }
-
- /**
- * Mathhelper
- */
- private fun mathhelperA(var0: Double, var2: Double, var4: Double): Double {
- return if (var0 < var2) {
- var2
- } else {
- if (var0 > var4) var4 else var0
- }
- }
-
-}
diff --git a/blockball-bukkit-plugin/src/main/resources/plugin-legacy.yml b/blockball-bukkit-plugin/src/main/resources/plugin-legacy.yml
new file mode 100644
index 000000000..076dcda70
--- /dev/null
+++ b/blockball-bukkit-plugin/src/main/resources/plugin-legacy.yml
@@ -0,0 +1,27 @@
+name: BlockBall
+version: 6.35.0
+author: Shynixn
+website: https://www.spigotmc.org/members/shynixn.63455/
+main: com.github.shynixn.blockball.bukkit.BlockBallPlugin
+softdepend: [WorldEdit, BossBarAPI, PlaceholderAPI, Vault]
+commands:
+ blockball:
+ description: Opens the arena creation UI.
+ usage: /
+ permission: blockball.command.admin
+ permission-message: You don't have permission.
+ blockballstop:
+ description: Stops a running blockball game.
+ usage: /
+ permission: blockball.command.admin
+ permission-message: You don't have permission.
+ blockballbungeecord:
+ description: Adds a new bungeecord sign for connecting to other BlockBall servers.
+ usage: /
+ permission: blockball.command.admin
+ permission-message: You don't have permission.
+ blockballreload:
+ description: Reloads Blockball configuration and restarts all games.
+ usage: /
+ permission: blockball.command.reload
+ permission-message: You don't have permission.
diff --git a/blockball-bukkit-plugin/src/main/resources/plugin.yml b/blockball-bukkit-plugin/src/main/resources/plugin.yml
index 0f361f2df..39d19b782 100644
--- a/blockball-bukkit-plugin/src/main/resources/plugin.yml
+++ b/blockball-bukkit-plugin/src/main/resources/plugin.yml
@@ -1,9 +1,16 @@
name: BlockBall
-version: 6.34.2
+version: 6.35.0
author: Shynixn
website: https://www.spigotmc.org/members/shynixn.63455/
main: com.github.shynixn.blockball.bukkit.BlockBallPlugin
softdepend: [WorldEdit, BossBarAPI, PlaceholderAPI, Vault]
+libraries:
+ - 'org.slf4j:slf4j-jdk14:1.7.25'
+ - 'com.zaxxer:HikariCP:3.2.0'
+ - 'com.google.inject:guice:5.0.1'
+ - 'commons-io:commons-io:2.6'
+ - 'com.google.code.gson:gson:2.8.6'
+ - 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32'
commands:
blockball:
description: Opens the arena creation UI.
diff --git a/blockball-bukkit-plugin/src/test/java/unittest/BlockBallApiTest.kt b/blockball-bukkit-plugin/src/test/java/unittest/BlockBallApiTest.kt
index 20e6e4133..eba1b9d6c 100644
--- a/blockball-bukkit-plugin/src/test/java/unittest/BlockBallApiTest.kt
+++ b/blockball-bukkit-plugin/src/test/java/unittest/BlockBallApiTest.kt
@@ -3,8 +3,8 @@
package unittest
import com.github.shynixn.blockball.api.BlockBallApi
-import com.github.shynixn.blockball.api.business.enumeration.Version
import com.github.shynixn.blockball.api.business.proxy.PluginProxy
+import com.github.shynixn.mcutils.common.Version
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 504cc80b7..947facd2f 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -55,9 +55,9 @@
# built documents.
#
# The short X.Y version.
-version = '6.34.2'
+version = '6.35.0'
# The full version, including alpha/beta/rc tags.
-release = '6.34.2'
+release = '6.35.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 9a39073ae..474d130dd 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -2,12 +2,5 @@ rootProject.name = "blockball-root"
include("blockball-api")
include("blockball-bukkit-api")
include("blockball-bukkit-plugin")
-include("blockball-bukkit-plugin:bukkit-nms-117R1")
-include("blockball-bukkit-plugin:bukkit-nms-118R1")
-include("blockball-bukkit-plugin:bukkit-nms-118R2")
-include("blockball-bukkit-plugin:bukkit-nms-119R1")
-include("blockball-bukkit-plugin:bukkit-nms-119R2")
-include("blockball-bukkit-plugin:bukkit-nms-119R3")
-include("blockball-bukkit-plugin:bukkit-nms-120R1")
include("blockball-core")
include("blockball-tools")