Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRedMagic committed Jun 3, 2024
2 parents f28c07d + 406e978 commit ecc7f2c
Show file tree
Hide file tree
Showing 66 changed files with 58 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions .idea/modules/v1_20_5/UndefinedAPI.v1_20_5.main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 25 additions & 10 deletions api/src/main/java/com/redmagic/undefinedapi/nms/ServerPlayer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,39 @@ package com.redmagic.undefinedapi.nms
import com.google.gson.JsonObject
import com.google.gson.JsonParser
import java.io.InputStreamReader
import java.net.URL
import java.net.URI


fun NMSPlayer.toDeltaValue(value: Double, newValue: Double) = (((newValue - value) * 32 * 128).toInt().toShort())

fun NMSPlayer.toRotationValue(rotation: Float) = (((rotation % 360) * 256 / 360).toInt().toByte())

fun NMSPlayer.getSkinTexture(name: String): Array<String> {

val url = URL("https://api.mojang.com/users/profiles/minecraft/$name")
val reader = InputStreamReader(url.openStream())
val uuid = JsonParser().parse(reader).asJsonObject["id"].asString
fun NMSPlayer.getSkinTexture(name: String): Array<String> {

val url1 = URL("https://sessionserver.mojang.com/session/minecraft/profile/$uuid?unsigned=false")
val reader1 = InputStreamReader(url1.openStream())
val textureProperty: JsonObject = JsonParser().parse(reader1).asJsonObject.get("properties").asJsonArray.get(0).asJsonObject
val texture = textureProperty["value"].asString
val signature = textureProperty["signature"].asString
val textureProperty: JsonObject
var texture = "ewogICJ0aW1lc3RhbXAiIDogMTYyMTcxNTMxMjI5MCwKICAicHJvZmlsZUlkIiA6ICJiNTM5NTkyMjMwY2I0MmE0OWY5YTRlYmYxNmRlOTYwYiIsCiAgInByb2ZpbGVOYW1lIiA6ICJtYXJpYW5hZmFnIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzFhNGFmNzE4NDU1ZDRhYWI1MjhlN2E2MWY4NmZhMjVlNmEzNjlkMTc2OGRjYjEzZjdkZjMxOWE3MTNlYjgxMGIiCiAgICB9CiAgfQp9"
var signature = "otpbxDm9B+opW7jEzZF8BVDeZSqaqdF0dyLlnlyMh7Q5ysJFDL48/9J/IOHp8JqNm1oarmVdvxrroy9dlNI2Mz4BVuJM2pcCOJwk2h+aZ4dzNZGxst+MYNPSw+i4sMoYu7OV07UVHrQffolFF7MiaBUst1hFwM07IpTE6UtIQz4rqWisXe9Iz5+ooqX4wj0IB3dPntsh6u5nVlL8acWCBDAW4YqcPt2Y4CKK+KtskjzusjqGAdEO+4lRcW1S0ldo2RNtUHEzZADWQcADjg9KKiKq9QIpIpYURIoIAA+pDGb5Q8L5O6CGI+i1+FxqXbgdBvcm1EG0OPdw9WpSqAxGGeXSwlzjILvlvBzYbd6gnHFBhFO+X7iwRJYNd+qQakjUa6ZwR8NbkpbN3ABb9+6YqVkabaEmgfky3HdORE+bTp/AT6LHqEMQo0xdNkvF9gtFci7RWhFwuTLDvQ1esby1IhlgT+X32CPuVHuxEvPCjN7+lmRz2OyOZ4REo2tAIFUKakqu3nZ0NcF98b87wAdA9B9Qyd2H/rEtUToQhpBjP732Sov6TlJkb8echGYiLL5bu/Q7hum72y4+j2GNnuRiOJtJidPgDqrYMg81GfenfPyS6Ynw6KhdEhnwmJ1FJlJhYvXZyqZwLAV1c26DNYkrTMcFcv3VXmcd5/2Zn9FnZtw="

try {
val url = URI("https://api.mojang.com/users/profiles/minecraft/$name").toURL()
url.openStream().use { inputStream -> // Auto close InputStream
InputStreamReader(inputStream).use { reader -> // Auto close InputStreamReader
val uuid = JsonParser.parseReader(reader).asJsonObject["id"].asString

val url1 = URI("https://sessionserver.mojang.com/session/minecraft/profile/$uuid?unsigned=false").toURL()
url1.openStream().use { inputStream1 -> // Auto close InputStream
InputStreamReader(inputStream1).use { reader1 -> // Auto close InputStreamReader
textureProperty = JsonParser.parseReader(reader1).asJsonObject.get("properties").asJsonArray.get(0).asJsonObject
texture = textureProperty["value"].asString ?: texture
signature = textureProperty["signature"].asString ?: signature
}
}
}
}
} catch (e: Exception) {
println("Failed to get texture: ${e.message}")
}

return arrayOf(texture, signature)
}
3 changes: 1 addition & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.storage.CacheResetOnProcessCanceled.enabled

plugins {
`java-library`
Expand Down Expand Up @@ -81,7 +80,7 @@ allprojects {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("net.kyori:adventure-platform-bukkit:4.3.2")
implementation("net.kyori:adventure-text-minimessage:4.16.0")
implementation("org.json:json:20171018")
implementation("org.json:json:20231013")
implementation("com.googlecode.json-simple:json-simple:1.1.1")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import net.kyori.adventure.text.Component
import net.md_5.bungee.api.ChatMessageType
import net.md_5.bungee.api.chat.TextComponent
import org.bukkit.Bukkit
import org.bukkit.attribute.Attribute
import org.bukkit.entity.Player

/**
Expand Down Expand Up @@ -36,7 +37,6 @@ fun Player.sendActionBar(string: String){
*
* @param string The message to be displayed in the action bar.
* @param time The duration in ticks for which the message should be displayed.
* @param timeUnit The time unit for the duration. Defaults to TimeUnit.TICKS.
*/
fun Player.sendActionBar(string: String, time: Int) = sendActionBar(string, time, TimeUnit.TICKS)

Expand All @@ -53,10 +53,8 @@ fun Player.feed() { foodLevel = 20 }
* This method sets the player's health to the maximum health value specified by the "maxHealth" property.
* After calling this method, the player will be fully healed and have no health deficit.
*
* @see Player.health
* @see Player.maxHealth
*/
fun Player.heal() { health = maxHealth }
fun Player.heal() { health = this.getAttribute(Attribute.GENERIC_MAX_HEALTH)!!.value }

/**
* Resets the walk speed of the player to the default value.
Expand All @@ -75,7 +73,6 @@ fun Player.resetWalkSpeed() { walkSpeed = 0.2F }
* Resets the fly speed of the player to the default value.
* The default fly speed is 0.1F.
*
* @see Player.flySpeed
*/
fun Player.resetFlySpeed() { flySpeed = 0.1F }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,5 @@ fun Inventory.emptySlots(): Int{
* @param material The material to be counted.
* @return The total amount of the given material in the inventory.
*/
fun Inventory.getAmountOf(material: Material): Int = filter { it?.type == material }.sumBy { it?.amount ?: 0 }
fun Inventory.getAmountOf(material: Material): Int = filter { it?.type == material }.sumOf { it?.amount ?: 0 }

12 changes: 0 additions & 12 deletions common/src/main/java/com/redmagic/undefinedapi/menu/MenuUtil.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.redmagic.undefinedapi.menu.page

import com.google.gson.annotations.Until
import com.redmagic.undefinedapi.extension.string.emptySlots
import com.redmagic.undefinedapi.menu.MenuSize
import com.redmagic.undefinedapi.menu.normal.UndefinedMenu
Expand All @@ -10,7 +9,6 @@ import org.bukkit.Bukkit
import org.bukkit.Material
import org.bukkit.inventory.Inventory
import org.bukkit.inventory.ItemStack
import org.jetbrains.annotations.MustBeInvokedByOverriders


/**
Expand Down Expand Up @@ -104,7 +102,7 @@ abstract class UndefinedPageMenu(private val title: String, private val size: In
fun nextPage(){

val items = pageList?.getPage(page + 1) ?: return
page++;
page++
inventory!!.clear()

itemsMap.forEach{
Expand All @@ -123,7 +121,7 @@ abstract class UndefinedPageMenu(private val title: String, private val size: In


val items: List<ItemStack> = pageList?.getPage(page - 1) ?: return
page--;
page--

inventory!!.clear()

Expand Down Expand Up @@ -170,13 +168,6 @@ abstract class UndefinedPageMenu(private val title: String, private val size: In
return inventory!!
}

/**
* Executes the specified code block when the onPress event occurs.
*
* @param clickData A lambda expression representing the ClickData associated with the event.
* It takes an instance of [ClickData] as the receiver and does not return a value.
*/
fun onPress(clickData: ClickData.() -> Unit){}

/**
* Sets the items in the menu's inventory.
Expand Down
2 changes: 1 addition & 1 deletion server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ tasks {
}

runServer {
minecraftVersion("1.20.6")
minecraftVersion("1.20.4")
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.redmagic.undefinedapi.npc

import net.minecraft.network.Connection
import net.minecraft.network.PacketListener
import net.minecraft.network.PacketSendListener
import net.minecraft.network.protocol.Packet
import net.minecraft.network.protocol.PacketFlow

import net.minecraft.network.Connection;
import net.minecraft.network.PacketListener;
import net.minecraft.network.PacketSendListener;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketFlow;

import java.net.SocketAddress;
import java.net.SocketAddress



Expand All @@ -17,7 +16,7 @@ import java.net.SocketAddress;
*
* @param flag the packet flow flag for the connection
*/
class EmptyConnection1_20_4(flag: PacketFlow? = null): Connection(flag) {
class EmptyConnection1_20_4(flag: PacketFlow? = null): Connection(flag!!) {
init {
channel = EmptyChannel1_20_4(null)
address = object : SocketAddress() {
Expand All @@ -42,6 +41,6 @@ class EmptyConnection1_20_4(flag: PacketFlow? = null): Connection(flag) {
override fun send(packet: Packet<*>, genericfuturelistener: PacketSendListener?, flag: Boolean) {
}

override fun setListener(pl: PacketListener?) {
override fun setListener(pl: PacketListener) {
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.redmagic.undefinedapi.npc

import net.minecraft.network.Connection
import net.minecraft.network.PacketSendListener
import net.minecraft.network.protocol.Packet
import net.minecraft.network.protocol.PacketFlow

import net.minecraft.network.Connection;
import net.minecraft.network.PacketListener;
import net.minecraft.network.PacketSendListener;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketFlow;

import java.net.SocketAddress;
import java.net.SocketAddress



Expand All @@ -17,7 +15,7 @@ import java.net.SocketAddress;
*
* @param flag the packet flow flag for the connection
*/
class EmptyConnection1_20_5(flag: PacketFlow? = null): Connection(flag) {
class EmptyConnection1_20_5(flag: PacketFlow? = null): Connection(flag!!) {
init {
channel = EmptyChannel1_20_5(null)
address = object : SocketAddress() {
Expand Down
4 changes: 2 additions & 2 deletions v1_20_6/.gradle/caches/paperweight/taskCache/reobfJar.log
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Command: C:\Users\lijnb\.jdks\corretto-21.0.3\bin\java.exe -Xmx1G -classpath C:\Users\lijnb\.gradle\caches\modules-2\files-2.1\net.fabricmc\tiny-remapper\0.10.2\7b43b2f5baba09a38834e317ea020f82aa78ddd6\tiny-remapper-0.10.2-fat.jar net.fabricmc.tinyremapper.Main C:\Users\lijnb\IdeaProjects\UndefinedAPI\v1_20_6\build\libs\v1_20_6-0.5.00-dev.jar C:\Users\lijnb\IdeaProjects\UndefinedAPI\v1_20_6\build\libs\v1_20_6-0.5.00.jar C:\Users\lijnb\.gradle\caches\paperweight-userdev\ff775525efc29c3503a07d1006e63e5695a742b7505cf63e157d49d32419c69f\module\io.papermc.paper\dev-bundle\1.20.6-R0.1-SNAPSHOT\paperweight\setupCache\extractDevBundle.dir\data\mojang+yarn-spigot-reobf.tiny mojang+yarn spigot C:\Users\lijnb\.gradle\caches\paperweight-userdev\ff775525efc29c3503a07d1006e63e5695a742b7505cf63e157d49d32419c69f\module\io.papermc.paper\dev-bundle\1.20.6-R0.1-SNAPSHOT\paperweight\setupCache\applyMojangMappedPaperclipPatch.jar --threads=1
Finished after 1484,59 ms.
Command: C:\Users\lijnb\.jdks\corretto-21.0.3\bin\java.exe -Xmx1G -classpath C:\Users\lijnb\.gradle\caches\modules-2\files-2.1\net.fabricmc\tiny-remapper\0.10.2\7b43b2f5baba09a38834e317ea020f82aa78ddd6\tiny-remapper-0.10.2-fat.jar net.fabricmc.tinyremapper.Main C:\Users\lijnb\IdeaProjects\UndefinedAPI\v1_20_6\build\libs\v1_20_6-0.5.01-dev.jar C:\Users\lijnb\IdeaProjects\UndefinedAPI\v1_20_6\build\libs\v1_20_6-0.5.01.jar C:\Users\lijnb\.gradle\caches\paperweight-userdev\ff775525efc29c3503a07d1006e63e5695a742b7505cf63e157d49d32419c69f\module\io.papermc.paper\dev-bundle\1.20.6-R0.1-SNAPSHOT\paperweight\setupCache\extractDevBundle.dir\data\mojang+yarn-spigot-reobf.tiny mojang+yarn spigot C:\Users\lijnb\.gradle\caches\paperweight-userdev\ff775525efc29c3503a07d1006e63e5695a742b7505cf63e157d49d32419c69f\module\io.papermc.paper\dev-bundle\1.20.6-R0.1-SNAPSHOT\paperweight\setupCache\applyMojangMappedPaperclipPatch.jar --threads=1
Finished after 2325.02 ms.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
14
7
0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified v1_20_6/build/kotlin/compileKotlin/cacheable/last-build.bin
Binary file not shown.
Binary file not shown.
Binary file modified v1_20_6/build/kotlin/compileKotlin/local-state/build-history.bin
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.redmagic.undefinedapi.npc


import net.minecraft.network.Connection;
import net.minecraft.network.PacketSendListener;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketFlow;
import net.minecraft.network.Connection
import net.minecraft.network.PacketSendListener
import net.minecraft.network.protocol.Packet
import net.minecraft.network.protocol.PacketFlow

import java.net.SocketAddress;
import java.net.SocketAddress



Expand All @@ -16,7 +16,7 @@ import java.net.SocketAddress;
*
* @param flag the packet flow flag for the connection
*/
class EmptyConnection1_20_6(flag: PacketFlow? = null): Connection(flag) {
class EmptyConnection1_20_6(flag: PacketFlow? = null): Connection(flag!!) {
init {
channel = EmptyChannel1_20_6(null)
address = object : SocketAddress() {
Expand Down

0 comments on commit ecc7f2c

Please sign in to comment.