From 41acc9d3768f675d7dac0f221204c7464ba36cc9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:15 +0000 Subject: [PATCH 01/40] Bump org.apache.maven.plugins:maven-surefire-plugin Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b59310f0..85f8111a 100644 --- a/pom.xml +++ b/pom.xml @@ -120,12 +120,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.4.0 + 3.5.0 org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From 12b322209a4de47691b07bb2bf6ad66a423e45c0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:18 +0000 Subject: [PATCH 02/40] Bump org.apache.maven.surefire:surefire-junit-platform in /nms/1_15 Bumps org.apache.maven.surefire:surefire-junit-platform from 3.2.5 to 3.5.0. --- updated-dependencies: - dependency-name: org.apache.maven.surefire:surefire-junit-platform dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b59310f0..174a4372 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From b964c1591e4ca30c30d7138a386bfeb517e2b68e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:20 +0000 Subject: [PATCH 03/40] Bump org.apache.maven.plugins:maven-surefire-plugin in /nms/1_15 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b59310f0..85f8111a 100644 --- a/pom.xml +++ b/pom.xml @@ -120,12 +120,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.4.0 + 3.5.0 org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From a60749b985d63aacb88c4f89fbd7934b7b3d6fce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:21 +0000 Subject: [PATCH 04/40] Bump org.apache.maven.plugins:maven-surefire-plugin in /nms/1_18_2 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b59310f0..85f8111a 100644 --- a/pom.xml +++ b/pom.xml @@ -120,12 +120,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.4.0 + 3.5.0 org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From 4309b5acc3db6b6821f60d324acff6a298d845a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:24 +0000 Subject: [PATCH 05/40] Bump org.apache.maven.surefire:surefire-junit-platform in /nms/1_18_2 Bumps org.apache.maven.surefire:surefire-junit-platform from 3.2.5 to 3.5.0. --- updated-dependencies: - dependency-name: org.apache.maven.surefire:surefire-junit-platform dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b59310f0..174a4372 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From 7faf354b6730c32a6569ade6b6022fc3657e6896 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:26 +0000 Subject: [PATCH 06/40] Bump org.apache.maven.surefire:surefire-junit-platform Bumps org.apache.maven.surefire:surefire-junit-platform from 3.2.5 to 3.5.0. --- updated-dependencies: - dependency-name: org.apache.maven.surefire:surefire-junit-platform dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b59310f0..174a4372 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From 192f0a13dc2bd9e1b13fe37c061501f79f6bcd6c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:28 +0000 Subject: [PATCH 07/40] Bump org.apache.maven.plugins:maven-surefire-plugin in /nms/1_19_4 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b59310f0..85f8111a 100644 --- a/pom.xml +++ b/pom.xml @@ -120,12 +120,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.4.0 + 3.5.0 org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From c9968581bd98752ffe228a177d9473a9328ccf91 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:29 +0000 Subject: [PATCH 08/40] Bump org.apache.maven.surefire:surefire-junit-platform in /nms/1_19_4 Bumps org.apache.maven.surefire:surefire-junit-platform from 3.2.5 to 3.5.0. --- updated-dependencies: - dependency-name: org.apache.maven.surefire:surefire-junit-platform dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b59310f0..174a4372 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From a37584a6d6f6c6e64540568b527483fadc73ecfc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:31 +0000 Subject: [PATCH 09/40] Bump org.apache.maven.plugins:maven-surefire-plugin in /nms/1_20_5 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b59310f0..85f8111a 100644 --- a/pom.xml +++ b/pom.xml @@ -120,12 +120,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.4.0 + 3.5.0 org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From 24acd69040b99f612fcde35a0c0a3d01b9da084c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:33 +0000 Subject: [PATCH 10/40] Bump org.apache.maven.plugins:maven-surefire-plugin in /nms/1_19_3 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b59310f0..85f8111a 100644 --- a/pom.xml +++ b/pom.xml @@ -120,12 +120,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.4.0 + 3.5.0 org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From 97d2c4a56ce0878c3350d4091f09245f9b2b7283 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:38 +0000 Subject: [PATCH 11/40] Bump org.apache.maven.surefire:surefire-junit-platform in /nms/1_18_0 Bumps org.apache.maven.surefire:surefire-junit-platform from 3.2.5 to 3.5.0. --- updated-dependencies: - dependency-name: org.apache.maven.surefire:surefire-junit-platform dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b59310f0..174a4372 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From 539e2e6897c0e147fffeaf5cb2ff282efa2200b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:39 +0000 Subject: [PATCH 12/40] Bump org.apache.maven.plugins:maven-surefire-plugin in /nms/1_18_0 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b59310f0..85f8111a 100644 --- a/pom.xml +++ b/pom.xml @@ -120,12 +120,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.4.0 + 3.5.0 org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From e60fe096760b42b2ee9b9e1819924e00b7f647fc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:41 +0000 Subject: [PATCH 13/40] Bump org.apache.maven.plugins:maven-surefire-plugin in /nms/1_20_6 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b59310f0..85f8111a 100644 --- a/pom.xml +++ b/pom.xml @@ -120,12 +120,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.4.0 + 3.5.0 org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From db7f7dbcee06826e4e30d2698cd8f479eb93367c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:45 +0000 Subject: [PATCH 14/40] Bump org.apache.maven.surefire:surefire-junit-platform in /nms/1_16_4-5 Bumps org.apache.maven.surefire:surefire-junit-platform from 3.2.5 to 3.5.0. --- updated-dependencies: - dependency-name: org.apache.maven.surefire:surefire-junit-platform dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b59310f0..174a4372 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From e3855082574dc309d61dd0cd5b0589fdd14b9c79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:48 +0000 Subject: [PATCH 15/40] Bump org.apache.maven.surefire:surefire-junit-platform Bumps org.apache.maven.surefire:surefire-junit-platform from 3.2.5 to 3.5.0. --- updated-dependencies: - dependency-name: org.apache.maven.surefire:surefire-junit-platform dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b59310f0..174a4372 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From 4b4760c5e36add198f96f47c52d1450a86764c4c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:50 +0000 Subject: [PATCH 16/40] Bump org.apache.maven.plugins:maven-surefire-plugin in /nms/1_19_2 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b59310f0..85f8111a 100644 --- a/pom.xml +++ b/pom.xml @@ -120,12 +120,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.4.0 + 3.5.0 org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From e9c79aa5f398c4b253714ee5874d1dd5d0adce48 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:51 +0000 Subject: [PATCH 17/40] Bump org.apache.maven.surefire:surefire-junit-platform in /nms/1_19_2 Bumps org.apache.maven.surefire:surefire-junit-platform from 3.2.5 to 3.5.0. --- updated-dependencies: - dependency-name: org.apache.maven.surefire:surefire-junit-platform dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b59310f0..174a4372 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From a87713cbb641238893a329849a6541122125404f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:54 +0000 Subject: [PATCH 18/40] Bump org.apache.maven.plugins:maven-surefire-plugin Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b59310f0..85f8111a 100644 --- a/pom.xml +++ b/pom.xml @@ -120,12 +120,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.4.0 + 3.5.0 org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From 08f93db6ef7602081f09e7697b31fb31343fa3bf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:43:55 +0000 Subject: [PATCH 19/40] Bump org.apache.maven.surefire:surefire-junit-platform Bumps org.apache.maven.surefire:surefire-junit-platform from 3.2.5 to 3.5.0. --- updated-dependencies: - dependency-name: org.apache.maven.surefire:surefire-junit-platform dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b59310f0..174a4372 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From 67bf4bffe43e081f236117eb0585cf8b69c2c68a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:44:05 +0000 Subject: [PATCH 20/40] Bump org.apache.maven.surefire:surefire-junit-platform Bumps org.apache.maven.surefire:surefire-junit-platform from 3.2.5 to 3.5.0. --- updated-dependencies: - dependency-name: org.apache.maven.surefire:surefire-junit-platform dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b59310f0..174a4372 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From d8b097f67700e355fcaa3c0f3d60107e314df5aa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:44:05 +0000 Subject: [PATCH 21/40] Bump org.apache.maven.plugins:maven-surefire-plugin Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b59310f0..85f8111a 100644 --- a/pom.xml +++ b/pom.xml @@ -120,12 +120,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.4.0 + 3.5.0 org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From 9e55d3bfedcbdc70bbc51f325eb0cf76d8555acc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:44:08 +0000 Subject: [PATCH 22/40] Bump org.apache.maven.surefire:surefire-junit-platform in /nms/1_16_2-3 Bumps org.apache.maven.surefire:surefire-junit-platform from 3.2.5 to 3.5.0. --- updated-dependencies: - dependency-name: org.apache.maven.surefire:surefire-junit-platform dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b59310f0..174a4372 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From 1b94b13df5d784e752f16a3986234e3116e552d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:44:10 +0000 Subject: [PATCH 23/40] Bump org.apache.maven.plugins:maven-surefire-plugin in /IF Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- IF/pom.xml | 4 ++-- pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/IF/pom.xml b/IF/pom.xml index d7779c62..5b238820 100644 --- a/IF/pom.xml +++ b/IF/pom.xml @@ -267,12 +267,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.2.5 + 3.5.0 org.apache.maven.surefire surefire-junit-platform - 3.2.5 + 3.5.0 diff --git a/pom.xml b/pom.xml index b59310f0..85f8111a 100644 --- a/pom.xml +++ b/pom.xml @@ -120,12 +120,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.4.0 + 3.5.0 org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From d1be21736ff4b8198421ebb09912ecd1592d651a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:44:13 +0000 Subject: [PATCH 24/40] Bump org.apache.maven.plugins:maven-surefire-plugin in /nms/1_20_0 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b59310f0..85f8111a 100644 --- a/pom.xml +++ b/pom.xml @@ -120,12 +120,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.4.0 + 3.5.0 org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From 67117a3932692c9ce687c70857ce865b9a9011f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 05:18:59 +0000 Subject: [PATCH 25/40] Bump org.junit.jupiter:junit-jupiter-engine from 5.10.2 to 5.11.0 in /IF Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.10.2 to 5.11.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.10.2...r5.11.0) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- IF/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IF/pom.xml b/IF/pom.xml index d7779c62..b1858d19 100644 --- a/IF/pom.xml +++ b/IF/pom.xml @@ -220,7 +220,7 @@ org.junit.jupiter junit-jupiter-engine - 5.10.2 + 5.11.0 test From 1b9a734d3af5fe9e5546e1f0abf0e169be186d15 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 05:19:10 +0000 Subject: [PATCH 26/40] Bump org.apache.maven.plugins:maven-gpg-plugin in /IF Bumps [org.apache.maven.plugins:maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.2.4 to 3.2.5. - [Release notes](https://github.com/apache/maven-gpg-plugin/releases) - [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.2.4...maven-gpg-plugin-3.2.5) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-gpg-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- IF/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IF/pom.xml b/IF/pom.xml index b1858d19..bb57e7c3 100644 --- a/IF/pom.xml +++ b/IF/pom.xml @@ -244,7 +244,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.4 + 3.2.5 sign-artifacts From 4fd880827d7dcb7951b114d6dea9ccbf4e2ce199 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 05:27:10 +0000 Subject: [PATCH 27/40] Bump net.kyori:adventure-text-logger-slf4j in /nms/1_20_3-4 Bumps [net.kyori:adventure-text-logger-slf4j](https://github.com/KyoriPowered/adventure) from 4.15.0 to 4.17.0. - [Release notes](https://github.com/KyoriPowered/adventure/releases) - [Commits](https://github.com/KyoriPowered/adventure/compare/v4.15.0...v4.17.0) --- updated-dependencies: - dependency-name: net.kyori:adventure-text-logger-slf4j dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- nms/1_20_3-4/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nms/1_20_3-4/pom.xml b/nms/1_20_3-4/pom.xml index 5253cfb7..c679a7a3 100644 --- a/nms/1_20_3-4/pom.xml +++ b/nms/1_20_3-4/pom.xml @@ -47,7 +47,7 @@ net.kyori adventure-text-logger-slf4j - 4.15.0 + 4.17.0 net.kyori From 2f7ed3c671b797f1db061ad52b69efa3c5474422 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 05:27:14 +0000 Subject: [PATCH 28/40] Bump net.kyori:adventure-text-minimessage in /nms/1_20_3-4 Bumps [net.kyori:adventure-text-minimessage](https://github.com/KyoriPowered/adventure) from 4.15.0 to 4.17.0. - [Release notes](https://github.com/KyoriPowered/adventure/releases) - [Commits](https://github.com/KyoriPowered/adventure/compare/v4.15.0...v4.17.0) --- updated-dependencies: - dependency-name: net.kyori:adventure-text-minimessage dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- nms/1_20_3-4/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nms/1_20_3-4/pom.xml b/nms/1_20_3-4/pom.xml index c679a7a3..232dd395 100644 --- a/nms/1_20_3-4/pom.xml +++ b/nms/1_20_3-4/pom.xml @@ -52,7 +52,7 @@ net.kyori adventure-text-minimessage - 4.15.0 + 4.17.0 net.kyori From bb53e87436727f6f620e62bdc7170fa046ef0b7c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 18:18:28 +0000 Subject: [PATCH 29/40] Bump org.apache.maven.plugins:maven-javadoc-plugin in /nms/1_17_0 Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.6.3 to 3.10.0. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.6.3...maven-javadoc-plugin-3.10.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b59310f0..6b7f93e2 100644 --- a/pom.xml +++ b/pom.xml @@ -161,7 +161,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.7.0 + 3.10.0 attach-javadocs From e4628cd42620a91f8d646ae6a01e7fcc610dc064 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 18:24:05 +0000 Subject: [PATCH 30/40] Bump org.apache.maven.plugins:maven-javadoc-plugin in /IF Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.6.3 to 3.10.0. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.6.3...maven-javadoc-plugin-3.10.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- IF/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IF/pom.xml b/IF/pom.xml index bb57e7c3..da7540e0 100644 --- a/IF/pom.xml +++ b/IF/pom.xml @@ -316,7 +316,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.7.0 + 3.10.0 attach-javadocs From 42d17a496ffec1734e053679cf13b920ab82867a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:42:45 +0000 Subject: [PATCH 31/40] Bump org.apache.maven.surefire:surefire-junit-platform in /nms/1_17_0 Bumps org.apache.maven.surefire:surefire-junit-platform from 3.2.5 to 3.5.0. --- updated-dependencies: - dependency-name: org.apache.maven.surefire:surefire-junit-platform dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6b7f93e2..f46b66a1 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ org.apache.maven.surefire surefire-junit-platform - 3.4.0 + 3.5.0 org.junit.jupiter From 0020e29d97348afb3ec6e659a6c56aee47ff2119 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:42:46 +0000 Subject: [PATCH 32/40] Bump org.apache.maven.plugins:maven-surefire-plugin in /nms/1_17_0 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f46b66a1..3ac4df64 100644 --- a/pom.xml +++ b/pom.xml @@ -120,7 +120,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.4.0 + 3.5.0 org.apache.maven.surefire From 6c2d52101d85829523a6e9ea8cf1796b8d18e50b Mon Sep 17 00:00:00 2001 From: stefvanschie Date: Tue, 22 Oct 2024 20:56:54 +0200 Subject: [PATCH 33/40] Fix NMS break for 1.21.1 The beacon, enchanting table, and stonecutter guis broke due to NMS changes. Bump to 0.10.18-SNAPSHOT. --- .github/dependabot.yml | 6 +- .github/workflows/auto-deploy.yml | 18 + .github/workflows/maven.yml | 18 + IF/pom.xml | 10 +- .../util/version/Version.java | 28 +- .../util/version/VersionMatcher.java | 48 ++- README.md | 23 +- adventure-support/pom.xml | 2 +- inventory-view/iv-abstract-class/pom.xml | 2 +- inventory-view/iv-abstraction/pom.xml | 2 +- inventory-view/iv-interface/pom.xml | 2 +- nms/1_14/pom.xml | 2 +- nms/1_15/pom.xml | 2 +- nms/1_16_1/pom.xml | 2 +- nms/1_16_2-3/pom.xml | 2 +- nms/1_16_4-5/pom.xml | 2 +- nms/1_17_0/pom.xml | 2 +- nms/1_17_1/pom.xml | 2 +- nms/1_18_0/pom.xml | 2 +- nms/1_18_1/pom.xml | 2 +- nms/1_18_2/pom.xml | 2 +- nms/1_19_0/pom.xml | 2 +- nms/1_19_1/pom.xml | 2 +- nms/1_19_2/pom.xml | 2 +- nms/1_19_3/pom.xml | 2 +- nms/1_19_4/pom.xml | 2 +- nms/1_20_0/pom.xml | 2 +- nms/1_20_1/pom.xml | 2 +- nms/1_20_2/pom.xml | 2 +- nms/1_20_3-4/pom.xml | 2 +- nms/1_20_5/pom.xml | 2 +- nms/1_20_6/pom.xml | 2 +- nms/1_21_0/pom.xml | 72 ++++ .../nms/v1_21_0}/AnvilInventoryImpl.java | 24 +- .../nms/v1_21_0/BeaconInventoryImpl.java | 202 +++++++++++ .../CartographyTableInventoryImpl.java | 18 +- .../EnchantingTableInventoryImpl.java | 22 +- .../nms/v1_21_0}/GrindstoneInventoryImpl.java | 20 +- .../nms/v1_21_0}/MerchantInventoryImpl.java | 12 +- .../v1_21_0}/SmithingTableInventoryImpl.java | 24 +- .../v1_21_0}/StonecutterInventoryImpl.java | 22 +- .../v1_21_0}/util/CustomInventoryUtil.java | 6 +- .../nms/v1_21_0}/util/TextHolderUtil.java | 10 +- nms/{1_21 => 1_21_1}/pom.xml | 4 +- .../nms/v1_21_1/AnvilInventoryImpl.java | 284 +++++++++++++++ .../nms/v1_21_1}/BeaconInventoryImpl.java | 19 +- .../CartographyTableInventoryImpl.java | 218 ++++++++++++ .../v1_21_1/EnchantingTableInventoryImpl.java | 220 ++++++++++++ .../nms/v1_21_1/GrindstoneInventoryImpl.java | 208 +++++++++++ .../nms/v1_21_1/MerchantInventoryImpl.java | 118 ++++++ .../v1_21_1/SmithingTableInventoryImpl.java | 335 ++++++++++++++++++ .../nms/v1_21_1/StonecutterInventoryImpl.java | 222 ++++++++++++ .../nms/v1_21_1/util/CustomInventoryUtil.java | 41 +++ .../nms/v1_21_1/util/TextHolderUtil.java | 67 ++++ nms/abstraction/pom.xml | 2 +- pom.xml | 5 +- 56 files changed, 2231 insertions(+), 145 deletions(-) create mode 100644 nms/1_21_0/pom.xml rename nms/{1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21 => 1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0}/AnvilInventoryImpl.java (95%) create mode 100644 nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/BeaconInventoryImpl.java rename nms/{1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21 => 1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0}/CartographyTableInventoryImpl.java (95%) rename nms/{1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21 => 1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0}/EnchantingTableInventoryImpl.java (93%) rename nms/{1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21 => 1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0}/GrindstoneInventoryImpl.java (94%) rename nms/{1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21 => 1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0}/MerchantInventoryImpl.java (95%) rename nms/{1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21 => 1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0}/SmithingTableInventoryImpl.java (96%) rename nms/{1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21 => 1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0}/StonecutterInventoryImpl.java (93%) rename nms/{1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21 => 1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0}/util/CustomInventoryUtil.java (91%) rename nms/{1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21 => 1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0}/util/TextHolderUtil.java (92%) rename nms/{1_21 => 1_21_1}/pom.xml (97%) create mode 100644 nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/AnvilInventoryImpl.java rename nms/{1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21 => 1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1}/BeaconInventoryImpl.java (94%) create mode 100644 nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/CartographyTableInventoryImpl.java create mode 100644 nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/EnchantingTableInventoryImpl.java create mode 100644 nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/GrindstoneInventoryImpl.java create mode 100644 nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/MerchantInventoryImpl.java create mode 100644 nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/SmithingTableInventoryImpl.java create mode 100644 nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/StonecutterInventoryImpl.java create mode 100644 nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/util/CustomInventoryUtil.java create mode 100644 nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/util/TextHolderUtil.java diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 18ab4d3d..fb2210cf 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -97,7 +97,11 @@ updates: schedule: interval: "daily" - package-ecosystem: "maven" - directory: "/nms/1_21" + directory: "/nms/1_21_0" + schedule: + interval: "daily" + - package-ecosystem: "maven" + directory: "/nms/1_21_1" schedule: interval: "daily" - package-ecosystem: "maven" diff --git a/.github/workflows/auto-deploy.yml b/.github/workflows/auto-deploy.yml index 721bab50..08de3d9a 100644 --- a/.github/workflows/auto-deploy.yml +++ b/.github/workflows/auto-deploy.yml @@ -105,6 +105,24 @@ jobs: java -jar BuildTools.jar --remapped --disable-java-check --dont-update java -jar BuildTools.jar --rev 1.20.6 --remapped --disable-java-check + + cd Bukkit + git checkout 2ec53f498e32b3af989cb24672fc54dfab087154 + cd .. + + cd CraftBukkit + git checkout 8ee6fd1b8db9896590aa321d0199453de1fc35db + cd .. + + cd Spigot + git checkout fb8fb722a327a2f9f097f2ded700ac5de8157408 + cd .. + + cd BuildData + git checkout ae1e7b1e31cd3a3892bb05a6ccdcecc48c73c455 + cd .. + + java -jar BuildTools.jar --remapped --disable-java-check --dont-update java -jar BuildTools.jar --rev 1.21.1 --remapped --disable-java-check cd ../ - name: Setup GPG keys diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 05f7da27..222b4f84 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -111,6 +111,24 @@ jobs: java -jar BuildTools.jar --remapped --disable-java-check --dont-update java -jar BuildTools.jar --rev 1.20.6 --remapped --disable-java-check + + cd Bukkit + git checkout 2ec53f498e32b3af989cb24672fc54dfab087154 + cd .. + + cd CraftBukkit + git checkout 8ee6fd1b8db9896590aa321d0199453de1fc35db + cd .. + + cd Spigot + git checkout fb8fb722a327a2f9f097f2ded700ac5de8157408 + cd .. + + cd BuildData + git checkout ae1e7b1e31cd3a3892bb05a6ccdcecc48c73c455 + cd .. + + java -jar BuildTools.jar --remapped --disable-java-check --dont-update java -jar BuildTools.jar --rev 1.21.1 --remapped --disable-java-check cd ../ - name: Build with Maven diff --git a/IF/pom.xml b/IF/pom.xml index da7540e0..94636687 100644 --- a/IF/pom.xml +++ b/IF/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../pom.xml 4.0.0 @@ -169,7 +169,13 @@ com.github.stefvanschie.inventoryframework - 1_21 + 1_21_0 + ${project.version} + compile + + + com.github.stefvanschie.inventoryframework + 1_21_1 ${project.version} compile diff --git a/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/Version.java b/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/Version.java index fa8fe3d6..1838a62a 100644 --- a/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/Version.java +++ b/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/Version.java @@ -164,11 +164,18 @@ public enum Version { V1_20_6, /** - * Version 1.21 + * Version 1.21.0 * - * @since 0.10.15 + * @since 0.10.18 */ - V1_21; + V1_21_0, + + /** + * Version 1.21.1 + * + * @since 0.10.18 + */ + V1_21_1; /** * A collection of versions on which modern smithing tables are available. @@ -176,7 +183,7 @@ public enum Version { private static final Collection MODERN_SMITHING_TABLE_VERSIONS = EnumSet.of( V1_19_4, V1_20_0, V1_20_1, V1_20_2, V1_20_3_4, V1_20_5, V1_20_6, - V1_21 + V1_21_0, V1_21_1 ); /** @@ -192,6 +199,14 @@ public enum Version { V1_19_0, V1_19_1, V1_19_2, V1_19_3, V1_19_4 ); + /** + * A collection of versions on which {@link InventoryView} is an interface. + */ + @NotNull + private static final Collection<@NotNull Version> INTERFACE_INVENTORY_VIEW = EnumSet.of( + V1_21_0, V1_21_1 + ); + /** * Checks whether the {@link InventoryView} class is an interface on this version. * @@ -200,7 +215,7 @@ public enum Version { */ @Contract(pure = true) public boolean isInventoryViewInterface() { - return this == Version.V1_21; + return INTERFACE_INVENTORY_VIEW.contains(this); } /** @@ -289,8 +304,9 @@ public static Version getVersion() { case "1.20.6": return V1_20_6; case "1.21": + return V1_21_0; case "1.21.1": - return V1_21; + return V1_21_1; default: throw new UnsupportedVersionException("The server version provided is not supported"); } diff --git a/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/VersionMatcher.java b/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/VersionMatcher.java index eceb0e85..331e7c01 100644 --- a/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/VersionMatcher.java +++ b/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/VersionMatcher.java @@ -317,8 +317,10 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_20_5.AnvilInventoryImpl.class); ANVIL_INVENTORIES.put(Version.V1_20_6, com.github.stefvanschie.inventoryframework.nms.v1_20_6.AnvilInventoryImpl.class); - ANVIL_INVENTORIES.put(Version.V1_21, - com.github.stefvanschie.inventoryframework.nms.v1_21.AnvilInventoryImpl.class); + ANVIL_INVENTORIES.put(Version.V1_21_0, + com.github.stefvanschie.inventoryframework.nms.v1_21_0.AnvilInventoryImpl.class); + ANVIL_INVENTORIES.put(Version.V1_21_1, + com.github.stefvanschie.inventoryframework.nms.v1_21_1.AnvilInventoryImpl.class); BEACON_INVENTORIES = new EnumMap<>(Version.class); BEACON_INVENTORIES.put(Version.V1_14, @@ -363,8 +365,10 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_20_5.BeaconInventoryImpl.class); BEACON_INVENTORIES.put(Version.V1_20_6, com.github.stefvanschie.inventoryframework.nms.v1_20_6.BeaconInventoryImpl.class); - BEACON_INVENTORIES.put(Version.V1_21, - com.github.stefvanschie.inventoryframework.nms.v1_21.BeaconInventoryImpl.class); + BEACON_INVENTORIES.put(Version.V1_21_0, + com.github.stefvanschie.inventoryframework.nms.v1_21_0.BeaconInventoryImpl.class); + BEACON_INVENTORIES.put(Version.V1_21_1, + com.github.stefvanschie.inventoryframework.nms.v1_21_1.BeaconInventoryImpl.class); CARTOGRAPHY_TABLE_INVENTORIES = new EnumMap<>(Version.class); CARTOGRAPHY_TABLE_INVENTORIES.put(Version.V1_14, @@ -409,8 +413,10 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_20_5.CartographyTableInventoryImpl.class); CARTOGRAPHY_TABLE_INVENTORIES.put(Version.V1_20_6, com.github.stefvanschie.inventoryframework.nms.v1_20_6.CartographyTableInventoryImpl.class); - CARTOGRAPHY_TABLE_INVENTORIES.put(Version.V1_21, - com.github.stefvanschie.inventoryframework.nms.v1_21.CartographyTableInventoryImpl.class); + CARTOGRAPHY_TABLE_INVENTORIES.put(Version.V1_21_0, + com.github.stefvanschie.inventoryframework.nms.v1_21_0.CartographyTableInventoryImpl.class); + CARTOGRAPHY_TABLE_INVENTORIES.put(Version.V1_21_1, + com.github.stefvanschie.inventoryframework.nms.v1_21_1.CartographyTableInventoryImpl.class); ENCHANTING_TABLE_INVENTORIES = new EnumMap<>(Version.class); ENCHANTING_TABLE_INVENTORIES.put(Version.V1_14, @@ -455,8 +461,10 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_20_5.EnchantingTableInventoryImpl.class); ENCHANTING_TABLE_INVENTORIES.put(Version.V1_20_6, com.github.stefvanschie.inventoryframework.nms.v1_20_6.EnchantingTableInventoryImpl.class); - ENCHANTING_TABLE_INVENTORIES.put(Version.V1_21, - com.github.stefvanschie.inventoryframework.nms.v1_21.EnchantingTableInventoryImpl.class); + ENCHANTING_TABLE_INVENTORIES.put(Version.V1_21_0, + com.github.stefvanschie.inventoryframework.nms.v1_21_0.EnchantingTableInventoryImpl.class); + ENCHANTING_TABLE_INVENTORIES.put(Version.V1_21_1, + com.github.stefvanschie.inventoryframework.nms.v1_21_1.EnchantingTableInventoryImpl.class); GRINDSTONE_INVENTORIES = new EnumMap<>(Version.class); GRINDSTONE_INVENTORIES.put(Version.V1_14, @@ -501,8 +509,10 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_20_5.GrindstoneInventoryImpl.class); GRINDSTONE_INVENTORIES.put(Version.V1_20_6, com.github.stefvanschie.inventoryframework.nms.v1_20_6.GrindstoneInventoryImpl.class); - GRINDSTONE_INVENTORIES.put(Version.V1_21, - com.github.stefvanschie.inventoryframework.nms.v1_21.GrindstoneInventoryImpl.class); + GRINDSTONE_INVENTORIES.put(Version.V1_21_0, + com.github.stefvanschie.inventoryframework.nms.v1_21_0.GrindstoneInventoryImpl.class); + GRINDSTONE_INVENTORIES.put(Version.V1_21_1, + com.github.stefvanschie.inventoryframework.nms.v1_21_1.GrindstoneInventoryImpl.class); MERCHANT_INVENTORIES = new EnumMap<>(Version.class); MERCHANT_INVENTORIES.put(Version.V1_14, @@ -547,8 +557,10 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_20_5.MerchantInventoryImpl.class); MERCHANT_INVENTORIES.put(Version.V1_20_6, com.github.stefvanschie.inventoryframework.nms.v1_20_6.MerchantInventoryImpl.class); - MERCHANT_INVENTORIES.put(Version.V1_21, - com.github.stefvanschie.inventoryframework.nms.v1_21.MerchantInventoryImpl.class); + MERCHANT_INVENTORIES.put(Version.V1_21_0, + com.github.stefvanschie.inventoryframework.nms.v1_21_0.MerchantInventoryImpl.class); + MERCHANT_INVENTORIES.put(Version.V1_21_1, + com.github.stefvanschie.inventoryframework.nms.v1_21_1.MerchantInventoryImpl.class); SMITHING_TABLE_INVENTORIES = new EnumMap<>(Version.class); SMITHING_TABLE_INVENTORIES.put(Version.V1_19_4, @@ -565,8 +577,10 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_20_5.SmithingTableInventoryImpl.class); SMITHING_TABLE_INVENTORIES.put(Version.V1_20_6, com.github.stefvanschie.inventoryframework.nms.v1_20_6.SmithingTableInventoryImpl.class); - SMITHING_TABLE_INVENTORIES.put(Version.V1_21, - com.github.stefvanschie.inventoryframework.nms.v1_21.SmithingTableInventoryImpl.class); + SMITHING_TABLE_INVENTORIES.put(Version.V1_21_0, + com.github.stefvanschie.inventoryframework.nms.v1_21_0.SmithingTableInventoryImpl.class); + SMITHING_TABLE_INVENTORIES.put(Version.V1_21_1, + com.github.stefvanschie.inventoryframework.nms.v1_21_1.SmithingTableInventoryImpl.class); LEGACY_SMITHING_TABLE_INVENTORIES = new EnumMap<>(Version.class); LEGACY_SMITHING_TABLE_INVENTORIES.put(Version.V1_16_1, @@ -639,7 +653,9 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_20_5.StonecutterInventoryImpl.class); STONECUTTER_INVENTORIES.put(Version.V1_20_6, com.github.stefvanschie.inventoryframework.nms.v1_20_6.StonecutterInventoryImpl.class); - STONECUTTER_INVENTORIES.put(Version.V1_21, - com.github.stefvanschie.inventoryframework.nms.v1_21.StonecutterInventoryImpl.class); + STONECUTTER_INVENTORIES.put(Version.V1_21_0, + com.github.stefvanschie.inventoryframework.nms.v1_21_0.StonecutterInventoryImpl.class); + STONECUTTER_INVENTORIES.put(Version.V1_21_1, + com.github.stefvanschie.inventoryframework.nms.v1_21_1.StonecutterInventoryImpl.class); } } diff --git a/README.md b/README.md index 18109e57..4d04840d 100644 --- a/README.md +++ b/README.md @@ -142,10 +142,10 @@ mvn paper-nms:init -pl nms/1_20_3-4 ``` ### Installing Spigot via BuildTools -For versions 1.20.5-1.20.6, we use BuildTools. To install these versions, we run the following commands. +For versions 1.20.5-1.21.1, we use BuildTools. To install these versions, we run the following commands. ``` wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar -O BuildTools.jar - + git clone https://hub.spigotmc.org/stash/scm/spigot/bukkit.git Bukkit cd Bukkit git checkout 304e83eb384c338546aa96eea51388e0e8407e26 @@ -167,8 +167,25 @@ git checkout a7f7c2118b877fde4cf0f32f1f730ffcdee8e9ee cd .. java -jar BuildTools.jar --remapped --disable-java-check --dont-update - java -jar BuildTools.jar --rev 1.20.6 --remapped --disable-java-check + +cd Bukkit +git checkout 2ec53f498e32b3af989cb24672fc54dfab087154 +cd .. + +cd CraftBukkit +git checkout 8ee6fd1b8db9896590aa321d0199453de1fc35db +cd .. + +cd Spigot +git checkout fb8fb722a327a2f9f097f2ded700ac5de8157408 +cd .. + +cd BuildData +git checkout ae1e7b1e31cd3a3892bb05a6ccdcecc48c73c455 +cd .. + +java -jar BuildTools.jar --remapped --disable-java-check --dont-update java -jar BuildTools.jar --rev 1.21.1 --remapped --disable-java-check ``` diff --git a/adventure-support/pom.xml b/adventure-support/pom.xml index 18a87595..2e95e746 100644 --- a/adventure-support/pom.xml +++ b/adventure-support/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT 4.0.0 diff --git a/inventory-view/iv-abstract-class/pom.xml b/inventory-view/iv-abstract-class/pom.xml index 7e93aa5e..bf33ff28 100644 --- a/inventory-view/iv-abstract-class/pom.xml +++ b/inventory-view/iv-abstract-class/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml diff --git a/inventory-view/iv-abstraction/pom.xml b/inventory-view/iv-abstraction/pom.xml index e8c41e99..1588aad1 100644 --- a/inventory-view/iv-abstraction/pom.xml +++ b/inventory-view/iv-abstraction/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml diff --git a/inventory-view/iv-interface/pom.xml b/inventory-view/iv-interface/pom.xml index d79270a6..8e389285 100644 --- a/inventory-view/iv-interface/pom.xml +++ b/inventory-view/iv-interface/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml diff --git a/nms/1_14/pom.xml b/nms/1_14/pom.xml index 4d8035bf..79d81892 100644 --- a/nms/1_14/pom.xml +++ b/nms/1_14/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/nms/1_15/pom.xml b/nms/1_15/pom.xml index 78de6860..faac5f27 100644 --- a/nms/1_15/pom.xml +++ b/nms/1_15/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/nms/1_16_1/pom.xml b/nms/1_16_1/pom.xml index 96402109..046d2491 100644 --- a/nms/1_16_1/pom.xml +++ b/nms/1_16_1/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/nms/1_16_2-3/pom.xml b/nms/1_16_2-3/pom.xml index ace906da..9fe11f67 100644 --- a/nms/1_16_2-3/pom.xml +++ b/nms/1_16_2-3/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/nms/1_16_4-5/pom.xml b/nms/1_16_4-5/pom.xml index e6372f49..a86dd079 100644 --- a/nms/1_16_4-5/pom.xml +++ b/nms/1_16_4-5/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/nms/1_17_0/pom.xml b/nms/1_17_0/pom.xml index 7d523f9f..3637330f 100644 --- a/nms/1_17_0/pom.xml +++ b/nms/1_17_0/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/nms/1_17_1/pom.xml b/nms/1_17_1/pom.xml index 0ab843dd..79444e41 100644 --- a/nms/1_17_1/pom.xml +++ b/nms/1_17_1/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/nms/1_18_0/pom.xml b/nms/1_18_0/pom.xml index 92549d97..2f5b42f7 100644 --- a/nms/1_18_0/pom.xml +++ b/nms/1_18_0/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/nms/1_18_1/pom.xml b/nms/1_18_1/pom.xml index 3db1fd53..47ff26df 100644 --- a/nms/1_18_1/pom.xml +++ b/nms/1_18_1/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/nms/1_18_2/pom.xml b/nms/1_18_2/pom.xml index 9cb915bd..4a50cdf9 100644 --- a/nms/1_18_2/pom.xml +++ b/nms/1_18_2/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/nms/1_19_0/pom.xml b/nms/1_19_0/pom.xml index 49ee1600..f998d8ac 100644 --- a/nms/1_19_0/pom.xml +++ b/nms/1_19_0/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/nms/1_19_1/pom.xml b/nms/1_19_1/pom.xml index 3b7b6d8e..9624357a 100644 --- a/nms/1_19_1/pom.xml +++ b/nms/1_19_1/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/nms/1_19_2/pom.xml b/nms/1_19_2/pom.xml index 2526e1c1..40998988 100644 --- a/nms/1_19_2/pom.xml +++ b/nms/1_19_2/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/nms/1_19_3/pom.xml b/nms/1_19_3/pom.xml index da030c6b..54fc8e0c 100644 --- a/nms/1_19_3/pom.xml +++ b/nms/1_19_3/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/nms/1_19_4/pom.xml b/nms/1_19_4/pom.xml index 5c059349..bc775d6e 100644 --- a/nms/1_19_4/pom.xml +++ b/nms/1_19_4/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/nms/1_20_0/pom.xml b/nms/1_20_0/pom.xml index 6f111cb8..86cc53ff 100644 --- a/nms/1_20_0/pom.xml +++ b/nms/1_20_0/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml diff --git a/nms/1_20_1/pom.xml b/nms/1_20_1/pom.xml index b575179c..8ccbc5ad 100644 --- a/nms/1_20_1/pom.xml +++ b/nms/1_20_1/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml diff --git a/nms/1_20_2/pom.xml b/nms/1_20_2/pom.xml index b85178e1..2edecfe6 100644 --- a/nms/1_20_2/pom.xml +++ b/nms/1_20_2/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml diff --git a/nms/1_20_3-4/pom.xml b/nms/1_20_3-4/pom.xml index 232dd395..81e41633 100644 --- a/nms/1_20_3-4/pom.xml +++ b/nms/1_20_3-4/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml diff --git a/nms/1_20_5/pom.xml b/nms/1_20_5/pom.xml index 7a7863a2..5bc065cb 100644 --- a/nms/1_20_5/pom.xml +++ b/nms/1_20_5/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml diff --git a/nms/1_20_6/pom.xml b/nms/1_20_6/pom.xml index 182ed06d..4ff77993 100644 --- a/nms/1_20_6/pom.xml +++ b/nms/1_20_6/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml diff --git a/nms/1_21_0/pom.xml b/nms/1_21_0/pom.xml new file mode 100644 index 00000000..1de4e00a --- /dev/null +++ b/nms/1_21_0/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + + com.github.stefvanschie.inventoryframework + IF-parent + 0.10.18-SNAPSHOT + ../../pom.xml + + + 1_21_0 + + + true + + + + + com.github.stefvanschie.inventoryframework + abstraction + ${project.version} + compile + + + org.spigotmc + spigot + 1.21-R0.1-SNAPSHOT + remapped-mojang + provided + + + + + + + net.md-5 + specialsource-maven-plugin + 2.0.3 + + + package + + remap + + remap-obf + + org.spigotmc:minecraft-server:1.21-R0.1-SNAPSHOT:txt:maps-mojang + true + org.spigotmc:spigot:1.21-R0.1-SNAPSHOT:jar:remapped-mojang + true + remapped-obf + + + + package + + remap + + remap-spigot + + ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + org.spigotmc:minecraft-server:1.21-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.21-R0.1-SNAPSHOT:jar:remapped-obf + + + + + + + \ No newline at end of file diff --git a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/AnvilInventoryImpl.java b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/AnvilInventoryImpl.java similarity index 95% rename from nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/AnvilInventoryImpl.java rename to nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/AnvilInventoryImpl.java index 82e0192d..b40c0243 100644 --- a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/AnvilInventoryImpl.java +++ b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/AnvilInventoryImpl.java @@ -1,9 +1,9 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21; +package com.github.stefvanschie.inventoryframework.nms.v1_21_0; import com.github.stefvanschie.inventoryframework.abstraction.AnvilInventory; import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; -import com.github.stefvanschie.inventoryframework.nms.v1_21.util.CustomInventoryUtil; -import com.github.stefvanschie.inventoryframework.nms.v1_21.util.TextHolderUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_0.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_0.util.TextHolderUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; @@ -29,9 +29,9 @@ import org.jetbrains.annotations.Nullable; /** - * Internal anvil inventory for 1.21 + * Internal anvil inventory for 1.21.0 * - * @since 0.10.15 + * @since 0.10.18 */ public class AnvilInventoryImpl extends AnvilInventory { @@ -136,7 +136,7 @@ public void clearCursor(@NotNull Player player) { * * @param player the player to set the cursor * @param item the item to set the cursor to - * @since 0.10.15 + * @since 0.10.18 * @deprecated no longer used internally */ @Deprecated @@ -152,7 +152,7 @@ private void setCursor(@NotNull Player player, @NotNull ItemStack item) { * * @param player the player to send the result item to * @param item the result item - * @since 0.10.15 + * @since 0.10.18 * @deprecated no longer used internally */ @Deprecated @@ -169,7 +169,7 @@ private void sendResultItem(@NotNull Player player, @NotNull ItemStack item) { * * @param nmsPlayer the player to get the container id for * @return the container id - * @since 0.10.15 + * @since 0.10.18 * @deprecated no longer used internally */ @Contract(pure = true) @@ -183,7 +183,7 @@ private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nms * * @param serverPlayer the player to get the player connection from * @return the player connection - * @since 0.10.15 + * @since 0.10.18 * @deprecated no longer used internally */ @NotNull @@ -198,7 +198,7 @@ private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverP * * @param player the player to get the server player from * @return the server player - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) @@ -209,7 +209,7 @@ private ServerPlayer getServerPlayer(@NotNull Player player) { /** * A custom container anvil for responding to item renaming * - * @since 0.10.15 + * @since 0.10.18 */ private class ContainerAnvilImpl extends AnvilMenu { @@ -218,7 +218,7 @@ private class ContainerAnvilImpl extends AnvilMenu { * * @param serverPlayer the player for whom this anvil container is * @param title the title of the inventory - * @since 0.10.15 + * @since 0.10.18 */ public ContainerAnvilImpl(@NotNull ServerPlayer serverPlayer, @NotNull Component title) { super(serverPlayer.nextContainerCounter(), serverPlayer.getInventory(), diff --git a/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/BeaconInventoryImpl.java b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/BeaconInventoryImpl.java new file mode 100644 index 00000000..90981e03 --- /dev/null +++ b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/BeaconInventoryImpl.java @@ -0,0 +1,202 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_0; + +import com.github.stefvanschie.inventoryframework.abstraction.BeaconInventory; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerPlayerConnection; +import net.minecraft.world.Container; +import net.minecraft.world.inventory.BeaconMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryBeacon; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_21_R1.inventory.view.CraftBeaconView; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.reflect.Field; + +/** + * Internal beacon inventory for 1.21.0 + * + * @since 0.10.18 + */ +public class BeaconInventoryImpl extends BeaconInventory { + + public BeaconInventoryImpl(@NotNull InventoryHolder inventoryHolder) { + super(inventoryHolder); + } + + @Override + public void openInventory(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + ContainerBeaconImpl containerBeacon = new ContainerBeaconImpl(serverPlayer, item); + + serverPlayer.containerMenu = containerBeacon; + + int id = containerBeacon.containerId; + Component beacon = Component.literal("Beacon"); + + serverPlayer.connection.send(new ClientboundOpenScreenPacket(id, MenuType.BEACON, beacon)); + + sendItem(player, item); + } + + @Override + public void sendItem(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + NonNullList items = NonNullList.of( + ItemStack.EMPTY, //the first item doesn't count for some reason, so send a dummy item + CraftItemStack.asNMSCopy(item) + ); + + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + ItemStack cursor = CraftItemStack.asNMSCopy(player.getItemOnCursor()); + ServerPlayerConnection playerConnection = getPlayerConnection(serverPlayer); + + playerConnection.send(new ClientboundContainerSetContentPacket(containerId, state, items, cursor)); + } + + @Override + public void clearCursor(@NotNull Player player) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, ItemStack.EMPTY)); + } + + /** + * Gets the container id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the container id for + * @return the container id + * @since 0.10.18 + */ + @Contract(pure = true) + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } + + /** + * Gets the player connection for the specified player + * + * @param serverPlayer the player to get the player connection from + * @return the player connection + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverPlayer) { + return serverPlayer.connection; + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * A custom container beacon + * + * @since 0.10.18 + */ + private class ContainerBeaconImpl extends BeaconMenu { + + /** + * The player for this beacon container + */ + @NotNull + private final Player player; + + /** + * The internal bukkit entity for this container beacon + */ + @Nullable + private CraftBeaconView bukkitEntity; + + /** + * Field for accessing the beacon field + */ + @NotNull + private final Field beaconField; + + public ContainerBeaconImpl(@NotNull ServerPlayer serverPlayer, @Nullable org.bukkit.inventory.ItemStack item) { + super(serverPlayer.nextContainerCounter(), serverPlayer.getInventory()); + + this.player = serverPlayer.getBukkitEntity(); + setTitle(Component.empty()); + + try { + //noinspection JavaReflectionMemberAccess + this.beaconField = BeaconMenu.class.getDeclaredField("s"); //beacon + this.beaconField.setAccessible(true); + } catch (NoSuchFieldException exception) { + throw new RuntimeException(exception); + } + + try { + ItemStack itemStack = CraftItemStack.asNMSCopy(item); + + ((Container) beaconField.get(this)).setItem(0, itemStack); + } catch (IllegalAccessException exception) { + throw new RuntimeException(exception); + } + } + + @NotNull + @Override + public CraftBeaconView getBukkitView() { + if (bukkitEntity == null) { + try { + Container container = (Container) beaconField.get(this); + + Inventory inventory = new CraftInventoryBeacon(container) { + @NotNull + @Contract(pure = true) + @Override + public InventoryHolder getHolder() { + return inventoryHolder; + } + }; + + this.bukkitEntity = new CraftBeaconView(player, inventory, this); + } catch (IllegalAccessException exception) { + throw new RuntimeException(exception); + } + } + + return bukkitEntity; + } + + @Contract(pure = true, value = "_ -> true") + @Override + public boolean stillValid(@Nullable net.minecraft.world.entity.player.Player nmsPlayer) { + return true; + } + + @Override + public void slotsChanged(Container container) {} + + @Override + public void removed(net.minecraft.world.entity.player.Player nmsPlayer) {} + + } +} diff --git a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/CartographyTableInventoryImpl.java b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/CartographyTableInventoryImpl.java similarity index 95% rename from nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/CartographyTableInventoryImpl.java rename to nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/CartographyTableInventoryImpl.java index 37216c68..ee1d9a23 100644 --- a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/CartographyTableInventoryImpl.java +++ b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/CartographyTableInventoryImpl.java @@ -1,9 +1,9 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21; +package com.github.stefvanschie.inventoryframework.nms.v1_21_0; import com.github.stefvanschie.inventoryframework.abstraction.CartographyTableInventory; import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; -import com.github.stefvanschie.inventoryframework.nms.v1_21.util.CustomInventoryUtil; -import com.github.stefvanschie.inventoryframework.nms.v1_21.util.TextHolderUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_0.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_0.util.TextHolderUtil; import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; @@ -29,9 +29,9 @@ import java.lang.reflect.Field; /** - * Internal cartography table inventory for 1.21 + * Internal cartography table inventory for 1.21.0 * - * @since 0.10.15 + * @since 0.10.18 */ public class CartographyTableInventoryImpl extends CartographyTableInventory { @@ -92,7 +92,7 @@ public void clearCursor(@NotNull Player player) { * * @param nmsPlayer the player to get the container id for * @return the container id - * @since 0.10.15 + * @since 0.10.18 */ @Contract(pure = true) private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { @@ -104,7 +104,7 @@ private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nms * * @param serverPlayer the player to get the player connection from * @return the player connection - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) @@ -117,7 +117,7 @@ private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverP * * @param player the player to get the server player from * @return the server player - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) @@ -128,7 +128,7 @@ private ServerPlayer getServerPlayer(@NotNull Player player) { /** * A custom container cartography table * - * @since 0.10.15 + * @since 0.10.18 */ private class ContainerCartographyTableImpl extends CartographyTableMenu { diff --git a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/EnchantingTableInventoryImpl.java b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/EnchantingTableInventoryImpl.java similarity index 93% rename from nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/EnchantingTableInventoryImpl.java rename to nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/EnchantingTableInventoryImpl.java index 9bfd901a..01de8a79 100644 --- a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/EnchantingTableInventoryImpl.java +++ b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/EnchantingTableInventoryImpl.java @@ -1,8 +1,8 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21; +package com.github.stefvanschie.inventoryframework.nms.v1_21_0; import com.github.stefvanschie.inventoryframework.abstraction.EnchantingTableInventory; import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; -import com.github.stefvanschie.inventoryframework.nms.v1_21.util.TextHolderUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_0.util.TextHolderUtil; import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; @@ -15,11 +15,11 @@ import net.minecraft.world.inventory.MenuType; import net.minecraft.world.item.ItemStack; import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventory; import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryEnchanting; import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_21_R1.inventory.view.CraftEnchantmentView; import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -28,9 +28,9 @@ import java.lang.reflect.Field; /** - * Internal enchanting table inventory for 1.21 + * Internal enchanting table inventory for 1.21.0 * - * @since 0.10.15 + * @since 0.10.18 */ public class EnchantingTableInventoryImpl extends EnchantingTableInventory { @@ -94,7 +94,7 @@ public void clearCursor(@NotNull Player player) { * * @param nmsPlayer the player to get the containerId id for * @return the containerId id - * @since 0.10.15 + * @since 0.10.18 */ @Contract(pure = true) private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { @@ -106,7 +106,7 @@ private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nms * * @param serverPlayer the player to get the player connection from * @return the player connection - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) @@ -119,7 +119,7 @@ private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverP * * @param player the player to get the server player from * @return the server player - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) @@ -130,7 +130,7 @@ private ServerPlayer getServerPlayer(@NotNull Player player) { /** * A custom container enchanting table * - * @since 0.10.15 + * @since 0.10.18 */ private class ContainerEnchantingTableImpl extends EnchantmentMenu { @@ -184,7 +184,9 @@ public ContainerEnchantingTableImpl(@NotNull ServerPlayer serverPlayer, public CraftEnchantmentView getBukkitView() { if (bukkitEntity == null) { try { - CraftInventory inventory = new CraftInventoryEnchanting((Container) enchantSlotsField.get(this)) { + Container container = (Container) enchantSlotsField.get(this); + + Inventory inventory = new CraftInventoryEnchanting(container) { @NotNull @Contract(pure = true) @Override diff --git a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/GrindstoneInventoryImpl.java b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/GrindstoneInventoryImpl.java similarity index 94% rename from nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/GrindstoneInventoryImpl.java rename to nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/GrindstoneInventoryImpl.java index 34f2883e..59d5f89a 100644 --- a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/GrindstoneInventoryImpl.java +++ b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/GrindstoneInventoryImpl.java @@ -1,9 +1,9 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21; +package com.github.stefvanschie.inventoryframework.nms.v1_21_0; import com.github.stefvanschie.inventoryframework.abstraction.GrindstoneInventory; import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; -import com.github.stefvanschie.inventoryframework.nms.v1_21.util.CustomInventoryUtil; -import com.github.stefvanschie.inventoryframework.nms.v1_21.util.TextHolderUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_0.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_0.util.TextHolderUtil; import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; @@ -27,9 +27,9 @@ import org.jetbrains.annotations.Nullable; /** - * Internal grindstone inventory for 1.21 + * Internal grindstone inventory for 1.21.0 * - * @since 0.10.15 + * @since 0.10.18 */ public class GrindstoneInventoryImpl extends GrindstoneInventory { @@ -104,7 +104,7 @@ public void clearCursor(@NotNull Player player) { * * @param nmsPlayer the player to get the containerId id for * @return the containerId id - * @since 0.10.15 + * @since 0.10.18 * @deprecated no longer used internally */ @Contract(pure = true) @@ -118,7 +118,7 @@ private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nms * * @param serverPlayer the player to get the player connection from * @return the player connection - * @since 0.10.15 + * @since 0.10.18 * @deprecated no longer used internally */ @NotNull @@ -133,7 +133,7 @@ private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverP * * @param player the player to get the server player from * @return the server player - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) @@ -144,7 +144,7 @@ private ServerPlayer getServerPlayer(@NotNull Player player) { /** * A custom container grindstone * - * @since 0.10.15 + * @since 0.10.18 */ private static class ContainerGrindstoneImpl extends GrindstoneMenu { @@ -153,7 +153,7 @@ private static class ContainerGrindstoneImpl extends GrindstoneMenu { * * @param serverPlayer the player for whom this container should be opened * @param title the title of the gui - * @since 0.10.15 + * @since 0.10.18 */ public ContainerGrindstoneImpl(@NotNull ServerPlayer serverPlayer, @NotNull Component title) { super(serverPlayer.nextContainerCounter(), serverPlayer.getInventory()); diff --git a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/MerchantInventoryImpl.java b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/MerchantInventoryImpl.java similarity index 95% rename from nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/MerchantInventoryImpl.java rename to nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/MerchantInventoryImpl.java index b04be99e..489a02e5 100644 --- a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/MerchantInventoryImpl.java +++ b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/MerchantInventoryImpl.java @@ -1,4 +1,4 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21; +package com.github.stefvanschie.inventoryframework.nms.v1_21_0; import com.github.stefvanschie.inventoryframework.abstraction.MerchantInventory; import net.minecraft.core.component.DataComponentPredicate; @@ -19,9 +19,9 @@ import java.util.Optional; /** - * Internal merchant inventory for 1.21 + * Internal merchant inventory for 1.21.0 * - * @since 0.10.15 + * @since 0.10.18 */ public class MerchantInventoryImpl extends MerchantInventory { @@ -81,7 +81,7 @@ public void sendMerchantOffers(@NotNull Player player, * * @param itemStack the item stack to convert * @return the item cost - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(value = "_ -> new", pure = true) @@ -96,7 +96,7 @@ private ItemCost convertItemStackToItemCost(@NotNull net.minecraft.world.item.It * * @param player the player to get the server player from * @return the server player - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) @@ -109,7 +109,7 @@ private ServerPlayer getServerPlayer(@NotNull Player player) { * * @param nmsPlayer the player to get the containerId id for * @return the containerId id - * @since 0.10.15 + * @since 0.10.18 */ @Contract(pure = true) private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { diff --git a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/SmithingTableInventoryImpl.java b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/SmithingTableInventoryImpl.java similarity index 96% rename from nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/SmithingTableInventoryImpl.java rename to nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/SmithingTableInventoryImpl.java index 8e44a969..b3cb1100 100644 --- a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/SmithingTableInventoryImpl.java +++ b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/SmithingTableInventoryImpl.java @@ -1,9 +1,9 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21; +package com.github.stefvanschie.inventoryframework.nms.v1_21_0; import com.github.stefvanschie.inventoryframework.abstraction.SmithingTableInventory; import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; -import com.github.stefvanschie.inventoryframework.nms.v1_21.util.CustomInventoryUtil; -import com.github.stefvanschie.inventoryframework.nms.v1_21.util.TextHolderUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_0.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_0.util.TextHolderUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; @@ -29,9 +29,9 @@ import org.jetbrains.annotations.Nullable; /** - * Internal smithing table inventory for 1.21. This is only available for Minecraft 1.20 and higher. + * Internal smithing table inventory for 1.21.0. This is only available for Minecraft 1.20 and higher. * - * @since 0.10.15 + * @since 0.10.18 */ public class SmithingTableInventoryImpl extends SmithingTableInventory { @@ -139,7 +139,7 @@ public void clearCursor(@NotNull Player player) { * * @param player the player to set the cursor * @param item the item to set the cursor to - * @since 0.10.15 + * @since 0.10.18 * @deprecated no longer used internally */ @Deprecated @@ -155,7 +155,7 @@ private void setCursor(@NotNull Player player, @NotNull ItemStack item) { * * @param player the player to send the result item to * @param item the result item - * @since 0.10.15 + * @since 0.10.18 * @deprecated no longer used internally */ @Deprecated @@ -172,7 +172,7 @@ private void sendResultItem(@NotNull Player player, @NotNull ItemStack item) { * * @param nmsPlayer the player to get the container id for * @return the container id - * @since 0.10.15 + * @since 0.10.18 * @deprecated no longer used internally */ @Contract(pure = true) @@ -186,7 +186,7 @@ private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nms * * @param serverPlayer the player to get the player connection from * @return the player connection - * @since 0.10.15 + * @since 0.10.18 * @deprecated no longer used internally */ @NotNull @@ -201,7 +201,7 @@ private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverP * * @param player the player to get the server player from * @return the server player - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) @@ -212,7 +212,7 @@ private ServerPlayer getServerPlayer(@NotNull Player player) { /** * A custom container smithing table * - * @since 0.10.15 + * @since 0.10.18 */ private static class ContainerSmithingTableImpl extends SmithingMenu { @@ -221,7 +221,7 @@ private static class ContainerSmithingTableImpl extends SmithingMenu { * * @param serverPlayer the player for whom this anvil container is * @param title the title of the inventory - * @since 0.10.15 + * @since 0.10.18 */ public ContainerSmithingTableImpl(@NotNull ServerPlayer serverPlayer, @NotNull Component title) { super(serverPlayer.nextContainerCounter(), serverPlayer.getInventory(), diff --git a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/StonecutterInventoryImpl.java b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/StonecutterInventoryImpl.java similarity index 93% rename from nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/StonecutterInventoryImpl.java rename to nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/StonecutterInventoryImpl.java index 9cadfe56..d12e3e7f 100644 --- a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/StonecutterInventoryImpl.java +++ b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/StonecutterInventoryImpl.java @@ -1,8 +1,8 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21; +package com.github.stefvanschie.inventoryframework.nms.v1_21_0; import com.github.stefvanschie.inventoryframework.abstraction.StonecutterInventory; import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; -import com.github.stefvanschie.inventoryframework.nms.v1_21.util.TextHolderUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_0.util.TextHolderUtil; import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; @@ -15,11 +15,11 @@ import net.minecraft.world.inventory.StonecutterMenu; import net.minecraft.world.item.ItemStack; import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventory; import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryStonecutter; import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_21_R1.inventory.view.CraftStonecutterView; import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -28,9 +28,9 @@ import java.lang.reflect.Field; /** - * Internal stonecutter inventory for 1.21 + * Internal stonecutter inventory for 1.21.0 * - * @since 0.10.15 + * @since 0.10.18 */ public class StonecutterInventoryImpl extends StonecutterInventory { @@ -93,7 +93,7 @@ public void clearCursor(@NotNull Player player) { * * @param nmsPlayer the player to get the container id for * @return the container id - * @since 0.10.15 + * @since 0.10.18 */ @Contract(pure = true) private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { @@ -105,7 +105,7 @@ private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nms * * @param serverPlayer the player to get the player connection from * @return the player connection - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) @@ -118,7 +118,7 @@ private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverP * * @param player the player to get the server player from * @return the server player - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) @@ -129,7 +129,7 @@ private ServerPlayer getServerPlayer(@NotNull Player player) { /** * A custom container enchanting table * - * @since 0.10.15 + * @since 0.10.18 */ private class ContainerStonecutterImpl extends StonecutterMenu { @@ -175,7 +175,7 @@ public ContainerStonecutterImpl(@NotNull ServerPlayer entityPlayer, @Override public CraftStonecutterView getBukkitView() { if (bukkitEntity == null) { - CraftInventory inventory = new CraftInventoryStonecutter(this.container, getResultInventory()) { + Inventory inventory = new CraftInventoryStonecutter(this.container, getResultInventory()) { @NotNull @Contract(pure = true) @Override @@ -206,7 +206,7 @@ public void removed(net.minecraft.world.entity.player.Player nmsPlayer) {} * Gets the result inventory * * @return the result inventory - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) diff --git a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/util/CustomInventoryUtil.java b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/util/CustomInventoryUtil.java similarity index 91% rename from nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/util/CustomInventoryUtil.java rename to nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/util/CustomInventoryUtil.java index 0d1e7354..364fd9bc 100644 --- a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/util/CustomInventoryUtil.java +++ b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/util/CustomInventoryUtil.java @@ -1,4 +1,4 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21.util; +package com.github.stefvanschie.inventoryframework.nms.v1_21_0.util; import net.minecraft.core.NonNullList; import net.minecraft.world.item.ItemStack; @@ -10,7 +10,7 @@ /** * A utility class for custom inventories * - * @since 0.10.15 + * @since 0.10.18 */ public final class CustomInventoryUtil { @@ -25,7 +25,7 @@ private CustomInventoryUtil() {} * * @param items the items to convert * @return a list of converted items - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) diff --git a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/util/TextHolderUtil.java b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/util/TextHolderUtil.java similarity index 92% rename from nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/util/TextHolderUtil.java rename to nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/util/TextHolderUtil.java index 07864c3d..b0757a95 100644 --- a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/util/TextHolderUtil.java +++ b/nms/1_21_0/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_0/util/TextHolderUtil.java @@ -1,4 +1,4 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21.util; +package com.github.stefvanschie.inventoryframework.nms.v1_21_0.util; import com.github.stefvanschie.inventoryframework.adventuresupport.ComponentHolder; import com.github.stefvanschie.inventoryframework.adventuresupport.StringHolder; @@ -14,7 +14,7 @@ /** * A utility class for adding {@link TextHolder} support. * - * @since 0.10.15 + * @since 0.10.18 */ public final class TextHolderUtil { @@ -27,7 +27,7 @@ private TextHolderUtil() { * * @param holder the value to convert * @return the value as a vanilla component - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) @@ -44,7 +44,7 @@ public static Component toComponent(@NotNull TextHolder holder) { * * @param holder the value to convert * @return the value as a vanilla component - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) @@ -57,7 +57,7 @@ private static Component toComponent(@NotNull StringHolder holder) { * * @param holder the value to convert * @return the value as a vanilla component - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) diff --git a/nms/1_21/pom.xml b/nms/1_21_1/pom.xml similarity index 97% rename from nms/1_21/pom.xml rename to nms/1_21_1/pom.xml index 3ad1e532..fdb0750d 100644 --- a/nms/1_21/pom.xml +++ b/nms/1_21_1/pom.xml @@ -6,11 +6,11 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml - 1_21 + 1_21_1 true diff --git a/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/AnvilInventoryImpl.java b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/AnvilInventoryImpl.java new file mode 100644 index 00000000..807fb052 --- /dev/null +++ b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/AnvilInventoryImpl.java @@ -0,0 +1,284 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_1; + +import com.github.stefvanschie.inventoryframework.abstraction.AnvilInventory; +import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; +import com.github.stefvanschie.inventoryframework.nms.v1_21_1.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_1.util.TextHolderUtil; +import net.minecraft.core.BlockPos; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerPlayerConnection; +import net.minecraft.world.Container; +import net.minecraft.world.inventory.AnvilMenu; +import net.minecraft.world.inventory.ContainerLevelAccess; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R1.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Internal anvil inventory for 1.21.1 + * + * @since 0.10.18 + */ +public class AnvilInventoryImpl extends AnvilInventory { + + public AnvilInventoryImpl(@NotNull InventoryHolder inventoryHolder) { + super(inventoryHolder); + } + + @Override + public Inventory openInventory(@NotNull Player player, @NotNull TextHolder title, + @Nullable org.bukkit.inventory.ItemStack[] items) { + int itemAmount = items.length; + + if (itemAmount != 3) { + throw new IllegalArgumentException( + "The amount of items for an anvil should be 3, but is '" + itemAmount + "'" + ); + } + + ServerPlayer serverPlayer = getServerPlayer(player); + + //ignore deprecation: superseding method is only available on Paper + //noinspection deprecation + CraftEventFactory.handleInventoryCloseEvent(serverPlayer); + + serverPlayer.containerMenu = serverPlayer.inventoryMenu; + + Component message = TextHolderUtil.toComponent(title); + ContainerAnvilImpl containerAnvil = new ContainerAnvilImpl(serverPlayer, message); + + Inventory inventory = containerAnvil.getBukkitView().getTopInventory(); + + inventory.setItem(0, items[0]); + inventory.setItem(1, items[1]); + inventory.setItem(2, items[2]); + + int containerId = containerAnvil.getContainerId(); + + serverPlayer.connection.send(new ClientboundOpenScreenPacket(containerId, MenuType.ANVIL, message)); + serverPlayer.containerMenu = containerAnvil; + serverPlayer.initMenu(containerAnvil); + + return inventory; + } + + @Override + public void sendItems(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack[] items) { + NonNullList nmsItems = CustomInventoryUtil.convertToNMSItems(items); + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + ItemStack cursor = CraftItemStack.asNMSCopy(player.getItemOnCursor()); + ServerPlayerConnection playerConnection = getPlayerConnection(serverPlayer); + + playerConnection.send(new ClientboundContainerSetContentPacket(containerId, state, nmsItems, cursor)); + } + + @Override + public void sendFirstItem(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + ItemStack nmsItem = CraftItemStack.asNMSCopy(item); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(containerId, state, 0, nmsItem)); + } + + @Override + public void sendSecondItem(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + ItemStack nmsItem = CraftItemStack.asNMSCopy(item); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(containerId, state, 1, nmsItem)); + } + + @Override + public void sendResultItem(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + sendResultItem(player, CraftItemStack.asNMSCopy(item)); + } + + @Override + public void clearResultItem(@NotNull Player player) { + sendResultItem(player, ItemStack.EMPTY); + } + + @Override + public void setCursor(@NotNull Player player, @NotNull org.bukkit.inventory.ItemStack item) { + setCursor(player, CraftItemStack.asNMSCopy(item)); + } + + @Override + public void clearCursor(@NotNull Player player) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, ItemStack.EMPTY)); + } + + /** + * Sets the cursor of the given player + * + * @param player the player to set the cursor + * @param item the item to set the cursor to + * @since 0.10.18 + * @deprecated no longer used internally + */ + @Deprecated + private void setCursor(@NotNull Player player, @NotNull ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, item)); + } + + /** + * Sends the result item to the specified player with the given item + * + * @param player the player to send the result item to + * @param item the result item + * @since 0.10.18 + * @deprecated no longer used internally + */ + @Deprecated + private void sendResultItem(@NotNull Player player, @NotNull ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(containerId, state, 2, item)); + } + + /** + * Gets the container id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the container id for + * @return the container id + * @since 0.10.18 + * @deprecated no longer used internally + */ + @Contract(pure = true) + @Deprecated + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } + + /** + * Gets the player connection for the specified player + * + * @param serverPlayer the player to get the player connection from + * @return the player connection + * @since 0.10.18 + * @deprecated no longer used internally + */ + @NotNull + @Contract(pure = true) + @Deprecated + private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverPlayer) { + return serverPlayer.connection; + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * A custom container anvil for responding to item renaming + * + * @since 0.10.18 + */ + private class ContainerAnvilImpl extends AnvilMenu { + + /** + * Creates a new custom anvil container for the specified player + * + * @param serverPlayer the player for whom this anvil container is + * @param title the title of the inventory + * @since 0.10.18 + */ + public ContainerAnvilImpl(@NotNull ServerPlayer serverPlayer, @NotNull Component title) { + super(serverPlayer.nextContainerCounter(), serverPlayer.getInventory(), + ContainerLevelAccess.create(serverPlayer.getCommandSenderWorld(), new BlockPos(0, 0, 0))); + + this.checkReachable = false; + this.cost.set(AnvilInventoryImpl.super.cost); + + setTitle(title); + + Slot originalSlot = this.slots.get(2); + + this.slots.set(2, new Slot(originalSlot.container, originalSlot.index, originalSlot.x, originalSlot.y) { + @Override + public boolean mayPlace(@NotNull ItemStack stack) { + return true; + } + + @Override + public boolean mayPickup(net.minecraft.world.entity.player.@NotNull Player playerEntity) { + return true; + } + + @Override + public void onTake(net.minecraft.world.entity.player.@NotNull Player player, @NotNull ItemStack stack) { + originalSlot.onTake(player, stack); + } + }); + } + + @Override + public boolean setItemName(@Nullable String name) { + name = name == null ? "" : name; + + /* Only update if the name is actually different. This may be called even if the name is not different, + particularly when putting an item in the first slot. */ + if (!name.equals(AnvilInventoryImpl.super.observableText.get())) { + AnvilInventoryImpl.super.observableText.set(name); + } + + //the client predicts the output result, so we broadcast the state again to override it + broadcastFullState(); + return true; //no idea what this is for + } + + @Override + public void createResult() {} + + @Override + public void removed(net.minecraft.world.entity.player.@NotNull Player nmsPlayer) {} + + @Override + protected void clearContainer(net.minecraft.world.entity.player.@NotNull Player player, + @NotNull Container inventory) {} + + @Override + protected void onTake(net.minecraft.world.entity.player.@NotNull Player player, @NotNull ItemStack stack) {} + + public int getContainerId() { + return this.containerId; + } + } +} diff --git a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/BeaconInventoryImpl.java b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/BeaconInventoryImpl.java similarity index 94% rename from nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/BeaconInventoryImpl.java rename to nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/BeaconInventoryImpl.java index 0a8f689f..676d6064 100644 --- a/nms/1_21/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21/BeaconInventoryImpl.java +++ b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/BeaconInventoryImpl.java @@ -1,4 +1,4 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21; +package com.github.stefvanschie.inventoryframework.nms.v1_21_1; import com.github.stefvanschie.inventoryframework.abstraction.BeaconInventory; import net.minecraft.core.NonNullList; @@ -13,7 +13,6 @@ import net.minecraft.world.inventory.MenuType; import net.minecraft.world.item.ItemStack; import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventory; import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryBeacon; import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_21_R1.inventory.view.CraftBeaconView; @@ -26,9 +25,9 @@ import java.lang.reflect.Field; /** - * Internal beacon inventory for 1.21 + * Internal beacon inventory for 1.21.1 * - * @since 0.10.15 + * @since 0.10.18 */ public class BeaconInventoryImpl extends BeaconInventory { @@ -80,7 +79,7 @@ public void clearCursor(@NotNull Player player) { * * @param nmsPlayer the player to get the container id for * @return the container id - * @since 0.10.15 + * @since 0.10.18 */ @Contract(pure = true) private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { @@ -92,7 +91,7 @@ private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nms * * @param serverPlayer the player to get the player connection from * @return the player connection - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) @@ -105,7 +104,7 @@ private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverP * * @param player the player to get the server player from * @return the server player - * @since 0.10.15 + * @since 0.10.18 */ @NotNull @Contract(pure = true) @@ -116,7 +115,7 @@ private ServerPlayer getServerPlayer(@NotNull Player player) { /** * A custom container beacon * - * @since 0.10.15 + * @since 0.10.18 */ private class ContainerBeaconImpl extends BeaconMenu { @@ -166,7 +165,9 @@ public ContainerBeaconImpl(@NotNull ServerPlayer serverPlayer, @Nullable org.buk public CraftBeaconView getBukkitView() { if (bukkitEntity == null) { try { - CraftInventory inventory = new CraftInventoryBeacon((Container) beaconField.get(this)) { + Container container = (Container) beaconField.get(this); + + org.bukkit.inventory.BeaconInventory inventory = new CraftInventoryBeacon(container) { @NotNull @Contract(pure = true) @Override diff --git a/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/CartographyTableInventoryImpl.java b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/CartographyTableInventoryImpl.java new file mode 100644 index 00000000..f9a79e83 --- /dev/null +++ b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/CartographyTableInventoryImpl.java @@ -0,0 +1,218 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_1; + +import com.github.stefvanschie.inventoryframework.abstraction.CartographyTableInventory; +import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; +import com.github.stefvanschie.inventoryframework.nms.v1_21_1.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_1.util.TextHolderUtil; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerPlayerConnection; +import net.minecraft.world.Container; +import net.minecraft.world.inventory.CartographyTableMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventory; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryCartography; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryView; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.reflect.Field; + +/** + * Internal cartography table inventory for 1.21.1 + * + * @since 0.10.18 + */ +public class CartographyTableInventoryImpl extends CartographyTableInventory { + + public CartographyTableInventoryImpl(@NotNull InventoryHolder inventoryHolder) { + super(inventoryHolder); + } + + @Override + public void openInventory(@NotNull Player player, @NotNull TextHolder title, + @Nullable org.bukkit.inventory.ItemStack[] items) { + int itemAmount = items.length; + + if (itemAmount != 3) { + throw new IllegalArgumentException( + "The amount of items for a cartography table should be 3, but is '" + itemAmount + "'" + ); + } + + + ServerPlayer serverPlayer = getServerPlayer(player); + Component message = TextHolderUtil.toComponent(title); + + ContainerCartographyTableImpl containerCartographyTable = new ContainerCartographyTableImpl( + serverPlayer, items, message + ); + + serverPlayer.containerMenu = containerCartographyTable; + + int id = containerCartographyTable.containerId; + + serverPlayer.connection.send(new ClientboundOpenScreenPacket(id, MenuType.CARTOGRAPHY_TABLE, message)); + + sendItems(player, items); + } + + @Override + public void sendItems(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack[] items) { + NonNullList nmsItems = CustomInventoryUtil.convertToNMSItems(items); + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + ItemStack cursor = CraftItemStack.asNMSCopy(player.getItemOnCursor()); + ServerPlayerConnection playerConnection = getPlayerConnection(serverPlayer); + + playerConnection.send(new ClientboundContainerSetContentPacket(containerId, state, nmsItems, cursor)); + } + + @Override + public void clearCursor(@NotNull Player player) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, ItemStack.EMPTY)); + } + + /** + * Gets the container id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the container id for + * @return the container id + * @since 0.10.18 + */ + @Contract(pure = true) + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } + + /** + * Gets the player connection for the specified player + * + * @param serverPlayer the player to get the player connection from + * @return the player connection + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverPlayer) { + return serverPlayer.connection; + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * A custom container cartography table + * + * @since 0.10.18 + */ + private class ContainerCartographyTableImpl extends CartographyTableMenu { + + /** + * The player for this cartography table container + */ + @NotNull + private final Player player; + + /** + * The internal bukkit entity for this container cartography table + */ + @Nullable + private CraftInventoryView bukkitEntity; + + /** + * Field for accessing the result inventory field + */ + @NotNull + private final Field resultContainerField; + + public ContainerCartographyTableImpl(@NotNull ServerPlayer serverPlayer, + @Nullable org.bukkit.inventory.ItemStack[] items, + @NotNull Component title) { + super(serverPlayer.nextContainerCounter(), serverPlayer.getInventory()); + + this.player = serverPlayer.getBukkitEntity(); + + setTitle(title); + + try { + //noinspection JavaReflectionMemberAccess + this.resultContainerField = CartographyTableMenu.class.getDeclaredField("u"); //resultContainer + this.resultContainerField.setAccessible(true); + } catch (NoSuchFieldException exception) { + throw new RuntimeException(exception); + } + + container.setItem(0, CraftItemStack.asNMSCopy(items[0])); + container.setItem(1, CraftItemStack.asNMSCopy(items[1])); + + getResultInventory().setItem(0, CraftItemStack.asNMSCopy(items[2])); + } + + @NotNull + @Override + public CraftInventoryView getBukkitView() { + if (bukkitEntity == null) { + CraftInventory inventory = new CraftInventoryCartography(super.container, getResultInventory()) { + @NotNull + @Contract(pure = true) + @Override + public InventoryHolder getHolder() { + return inventoryHolder; + } + }; + + bukkitEntity = new CraftInventoryView(player, inventory, this); + } + + return bukkitEntity; + } + + @Contract(pure = true, value = "_ -> true") + @Override + public boolean stillValid(@Nullable net.minecraft.world.entity.player.Player nmsPlayer) { + return true; + } + + @Override + public void slotsChanged(Container container) {} + + @Override + public void removed(net.minecraft.world.entity.player.Player nmsPlayer) {} + + @NotNull + @Contract(pure = true) + private Container getResultInventory() { + try { + return (Container) resultContainerField.get(this); + } catch (IllegalAccessException exception) { + throw new RuntimeException(exception); + } + } + + } +} diff --git a/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/EnchantingTableInventoryImpl.java b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/EnchantingTableInventoryImpl.java new file mode 100644 index 00000000..0e29d26b --- /dev/null +++ b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/EnchantingTableInventoryImpl.java @@ -0,0 +1,220 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_1; + +import com.github.stefvanschie.inventoryframework.abstraction.EnchantingTableInventory; +import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; +import com.github.stefvanschie.inventoryframework.nms.v1_21_1.util.TextHolderUtil; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerPlayerConnection; +import net.minecraft.world.Container; +import net.minecraft.world.inventory.EnchantmentMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryEnchanting; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_21_R1.inventory.view.CraftEnchantmentView; +import org.bukkit.entity.Player; +import org.bukkit.inventory.EnchantingInventory; +import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.reflect.Field; + +/** + * Internal enchanting table inventory for 1.21.1 + * + * @since 0.10.18 + */ +public class EnchantingTableInventoryImpl extends EnchantingTableInventory { + + public EnchantingTableInventoryImpl(@NotNull InventoryHolder inventoryHolder) { + super(inventoryHolder); + } + + @Override + public void openInventory(@NotNull Player player, @NotNull TextHolder title, + @Nullable org.bukkit.inventory.ItemStack[] items) { + int itemAmount = items.length; + + if (itemAmount != 2) { + throw new IllegalArgumentException( + "The amount of items for an enchanting table should be 2, but is '" + itemAmount + "'" + ); + } + + ServerPlayer serverPlayer = getServerPlayer(player); + Component message = TextHolderUtil.toComponent(title); + ContainerEnchantingTableImpl containerEnchantmentTable = new ContainerEnchantingTableImpl( + serverPlayer, items, message + ); + + serverPlayer.containerMenu = containerEnchantmentTable; + + int id = containerEnchantmentTable.containerId; + + serverPlayer.connection.send(new ClientboundOpenScreenPacket(id, MenuType.ENCHANTMENT, message)); + + sendItems(player, items); + } + + @Override + public void sendItems(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack[] items) { + NonNullList nmsItems = NonNullList.of( + ItemStack.EMPTY, + CraftItemStack.asNMSCopy(items[0]), + CraftItemStack.asNMSCopy(items[1]) + ); + + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + ItemStack cursor = CraftItemStack.asNMSCopy(player.getItemOnCursor()); + ServerPlayerConnection playerConnection = getPlayerConnection(serverPlayer); + + playerConnection.send(new ClientboundContainerSetContentPacket(containerId, state, nmsItems, cursor)); + } + + @Override + public void clearCursor(@NotNull Player player) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, ItemStack.EMPTY)); + } + + /** + * Gets the containerId id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the containerId id for + * @return the containerId id + * @since 0.10.18 + */ + @Contract(pure = true) + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } + + /** + * Gets the player connection for the specified player + * + * @param serverPlayer the player to get the player connection from + * @return the player connection + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverPlayer) { + return serverPlayer.connection; + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * A custom container enchanting table + * + * @since 0.10.18 + */ + private class ContainerEnchantingTableImpl extends EnchantmentMenu { + + /** + * The player for this enchanting table container + */ + @NotNull + private final Player player; + + /** + * The internal bukkit entity for this container enchanting table + */ + @Nullable + private CraftEnchantmentView bukkitEntity; + + /** + * Field for accessing the enchant slots field + */ + @NotNull + private final Field enchantSlotsField; + + public ContainerEnchantingTableImpl(@NotNull ServerPlayer serverPlayer, + @Nullable org.bukkit.inventory.ItemStack[] items, + @NotNull Component title) { + super(serverPlayer.nextContainerCounter(), serverPlayer.getInventory()); + + this.player = serverPlayer.getBukkitEntity(); + + setTitle(title); + + try { + //noinspection JavaReflectionMemberAccess + this.enchantSlotsField = EnchantmentMenu.class.getDeclaredField("o"); //enchantSlots + this.enchantSlotsField.setAccessible(true); + } catch (NoSuchFieldException exception) { + throw new RuntimeException(exception); + } + + try { + Container input = (Container) enchantSlotsField.get(this); + + input.setItem(0, CraftItemStack.asNMSCopy(items[0])); + input.setItem(1, CraftItemStack.asNMSCopy(items[1])); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + + @NotNull + @Override + public CraftEnchantmentView getBukkitView() { + if (bukkitEntity == null) { + try { + Container container = (Container) enchantSlotsField.get(this); + + EnchantingInventory inventory = new CraftInventoryEnchanting(container) { + @NotNull + @Contract(pure = true) + @Override + public InventoryHolder getHolder() { + return inventoryHolder; + } + }; + + this.bukkitEntity = new CraftEnchantmentView(player, inventory, this); + } catch (IllegalAccessException exception) { + exception.printStackTrace(); + } + } + + return bukkitEntity; + } + + @Contract(pure = true, value = "_ -> true") + @Override + public boolean stillValid(@Nullable net.minecraft.world.entity.player.Player nmsPlayer) { + return true; + } + + @Override + public void slotsChanged(Container container) {} + + @Override + public void removed(net.minecraft.world.entity.player.Player nmsPlayer) {} + + } +} diff --git a/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/GrindstoneInventoryImpl.java b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/GrindstoneInventoryImpl.java new file mode 100644 index 00000000..ba8297b7 --- /dev/null +++ b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/GrindstoneInventoryImpl.java @@ -0,0 +1,208 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_1; + +import com.github.stefvanschie.inventoryframework.abstraction.GrindstoneInventory; +import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; +import com.github.stefvanschie.inventoryframework.nms.v1_21_1.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_1.util.TextHolderUtil; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerPlayerConnection; +import net.minecraft.world.Container; +import net.minecraft.world.inventory.GrindstoneMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R1.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Internal grindstone inventory for 1.21.1 + * + * @since 0.10.18 + */ +public class GrindstoneInventoryImpl extends GrindstoneInventory { + + public GrindstoneInventoryImpl(@NotNull InventoryHolder inventoryHolder) { + super(inventoryHolder); + } + + @Override + public Inventory openInventory(@NotNull Player player, @NotNull TextHolder title, + @Nullable org.bukkit.inventory.ItemStack[] items) { + int itemAmount = items.length; + + if (itemAmount != 3) { + throw new IllegalArgumentException( + "The amount of items for a grindstone should be 3, but is '" + itemAmount + "'" + ); + } + + ServerPlayer serverPlayer = getServerPlayer(player); + + //ignore deprecation: superseding method is only available on Paper + //noinspection deprecation + CraftEventFactory.handleInventoryCloseEvent(serverPlayer); + + serverPlayer.containerMenu = serverPlayer.inventoryMenu; + + Component message = TextHolderUtil.toComponent(title); + ContainerGrindstoneImpl containerGrindstone = new ContainerGrindstoneImpl(serverPlayer, message); + + Inventory inventory = containerGrindstone.getBukkitView().getTopInventory(); + + inventory.setItem(0, items[0]); + inventory.setItem(1, items[1]); + inventory.setItem(2, items[2]); + + int containerId = containerGrindstone.getContainerId(); + + serverPlayer.connection.send(new ClientboundOpenScreenPacket(containerId, MenuType.GRINDSTONE, message)); + serverPlayer.containerMenu = containerGrindstone; + serverPlayer.initMenu(containerGrindstone); + + return inventory; + } + + @Override + public void sendItems(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack[] items, + @Nullable org.bukkit.inventory.ItemStack cursor) { + if (cursor == null) { + throw new IllegalArgumentException("Cursor may not be null on version 1.19.2"); + } + + NonNullList nmsItems = CustomInventoryUtil.convertToNMSItems(items); + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + ItemStack nmsCursor = CraftItemStack.asNMSCopy(cursor); + ServerPlayerConnection playerConnection = getPlayerConnection(serverPlayer); + + playerConnection.send(new ClientboundContainerSetContentPacket(containerId, state, nmsItems, nmsCursor)); + } + + @Override + public void clearCursor(@NotNull Player player) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, ItemStack.EMPTY)); + } + + /** + * Gets the containerId id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the containerId id for + * @return the containerId id + * @since 0.10.18 + * @deprecated no longer used internally + */ + @Contract(pure = true) + @Deprecated + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } + + /** + * Gets the player connection for the specified player + * + * @param serverPlayer the player to get the player connection from + * @return the player connection + * @since 0.10.18 + * @deprecated no longer used internally + */ + @NotNull + @Contract(pure = true) + @Deprecated + private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverPlayer) { + return serverPlayer.connection; + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * A custom container grindstone + * + * @since 0.10.18 + */ + private static class ContainerGrindstoneImpl extends GrindstoneMenu { + + /** + * Creates a new grindstone container + * + * @param serverPlayer the player for whom this container should be opened + * @param title the title of the gui + * @since 0.10.18 + */ + public ContainerGrindstoneImpl(@NotNull ServerPlayer serverPlayer, @NotNull Component title) { + super(serverPlayer.nextContainerCounter(), serverPlayer.getInventory()); + + setTitle(title); + + Slot firstSlot = this.slots.get(0); + Slot secondSlot = this.slots.get(1); + Slot thirdSlot = this.slots.get(2); + + this.slots.set(0, new Slot(firstSlot.container, firstSlot.index, firstSlot.x, firstSlot.y) { + @Override + public boolean mayPlace(ItemStack stack) { + return true; + } + }); + + this.slots.set(1, new Slot(secondSlot.container, secondSlot.index, secondSlot.x, secondSlot.y) { + @Override + public boolean mayPlace(ItemStack stack) { + return true; + } + }); + + this.slots.set(2, new Slot(thirdSlot.container, thirdSlot.index, thirdSlot.x, thirdSlot.y) { + @Override + public boolean mayPlace(ItemStack stack) { + return true; + } + + @Override + public void onTake(net.minecraft.world.entity.player.Player player, ItemStack stack) {} + }); + } + + @Contract(pure = true, value = "_ -> true") + @Override + public boolean stillValid(@Nullable net.minecraft.world.entity.player.Player nmsPlayer) { + return true; + } + + @Override + public void slotsChanged(Container container) {} + + @Override + public void removed(net.minecraft.world.entity.player.Player nmsPlayer) {} + + public int getContainerId() { + return this.containerId; + } + } +} diff --git a/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/MerchantInventoryImpl.java b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/MerchantInventoryImpl.java new file mode 100644 index 00000000..97aed260 --- /dev/null +++ b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/MerchantInventoryImpl.java @@ -0,0 +1,118 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_1; + +import com.github.stefvanschie.inventoryframework.abstraction.MerchantInventory; +import net.minecraft.core.component.DataComponentPredicate; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.trading.ItemCost; +import net.minecraft.world.item.trading.MerchantOffer; +import net.minecraft.world.item.trading.MerchantOffers; +import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.MerchantRecipe; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * Internal merchant inventory for 1.21.1 + * + * @since 0.10.18 + */ +public class MerchantInventoryImpl extends MerchantInventory { + + @Override + public void sendMerchantOffers(@NotNull Player player, + @NotNull List> trades, + int level, int experience) { + MerchantOffers offers = new MerchantOffers(); + + for (Map.Entry entry : trades) { + MerchantRecipe recipe = entry.getKey(); + List ingredients = recipe.getIngredients(); + + if (ingredients.size() < 1) { + throw new IllegalStateException("Merchant recipe has no ingredients"); + } + + ItemStack itemA = ingredients.get(0); + ItemStack itemB = null; + + if (ingredients.size() >= 2) { + itemB = ingredients.get(1); + } + + net.minecraft.world.item.ItemStack nmsItemA = CraftItemStack.asNMSCopy(itemA); + net.minecraft.world.item.ItemStack nmsItemB = net.minecraft.world.item.ItemStack.EMPTY; + net.minecraft.world.item.ItemStack nmsItemResult = CraftItemStack.asNMSCopy(recipe.getResult()); + + if (itemB != null) { + nmsItemB = CraftItemStack.asNMSCopy(itemB); + } + + ItemCost itemCostA = convertItemStackToItemCost(nmsItemA); + ItemCost itemCostB = convertItemStackToItemCost(nmsItemB); + + int uses = recipe.getUses(); + int maxUses = recipe.getMaxUses(); + int exp = recipe.getVillagerExperience(); + float multiplier = recipe.getPriceMultiplier(); + + MerchantOffer merchantOffer = new MerchantOffer( + itemCostA, Optional.of(itemCostB), nmsItemResult, uses, maxUses, exp, multiplier + ); + merchantOffer.setSpecialPriceDiff(entry.getValue()); + + offers.add(merchantOffer); + } + + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + + serverPlayer.sendMerchantOffers(containerId, offers, level, experience, true, false); + } + + /** + * Converts an NMS item stack to an item cost. + * + * @param itemStack the item stack to convert + * @return the item cost + * @since 0.10.18 + */ + @NotNull + @Contract(value = "_ -> new", pure = true) + private ItemCost convertItemStackToItemCost(@NotNull net.minecraft.world.item.ItemStack itemStack) { + DataComponentPredicate predicate = DataComponentPredicate.allOf(itemStack.getComponents()); + + return new ItemCost(itemStack.getItemHolder(), itemStack.getCount(), predicate, itemStack); + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * Gets the containerId id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the containerId id for + * @return the containerId id + * @since 0.10.18 + */ + @Contract(pure = true) + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } +} diff --git a/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/SmithingTableInventoryImpl.java b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/SmithingTableInventoryImpl.java new file mode 100644 index 00000000..1e1cdb77 --- /dev/null +++ b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/SmithingTableInventoryImpl.java @@ -0,0 +1,335 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_1; + +import com.github.stefvanschie.inventoryframework.abstraction.SmithingTableInventory; +import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; +import com.github.stefvanschie.inventoryframework.nms.v1_21_1.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_1.util.TextHolderUtil; +import net.minecraft.core.BlockPos; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerPlayerConnection; +import net.minecraft.world.Container; +import net.minecraft.world.inventory.ContainerLevelAccess; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.inventory.SmithingMenu; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R1.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Internal smithing table inventory for 1.21.1. This is only available for Minecraft 1.20 and higher. + * + * @since 0.10.18 + */ +public class SmithingTableInventoryImpl extends SmithingTableInventory { + + public SmithingTableInventoryImpl(@NotNull InventoryHolder inventoryHolder) { + super(inventoryHolder); + } + + @NotNull + @Override + public Inventory openInventory(@NotNull Player player, @NotNull TextHolder title, + @Nullable org.bukkit.inventory.ItemStack[] items) { + int itemAmount = items.length; + + if (itemAmount != 4) { + throw new IllegalArgumentException( + "The amount of items for a smithing table should be 4, but is '" + itemAmount + "'" + ); + } + + ServerPlayer serverPlayer = getServerPlayer(player); + + //ignore deprecation: superseding method is only available on Paper + //noinspection deprecation + CraftEventFactory.handleInventoryCloseEvent(serverPlayer); + + serverPlayer.containerMenu = serverPlayer.inventoryMenu; + + Component message = TextHolderUtil.toComponent(title); + ContainerSmithingTableImpl containerSmithingTable = new ContainerSmithingTableImpl(serverPlayer, message); + + Inventory inventory = containerSmithingTable.getBukkitView().getTopInventory(); + + inventory.setItem(0, items[0]); + inventory.setItem(1, items[1]); + inventory.setItem(2, items[2]); + inventory.setItem(3, items[3]); + + int containerId = containerSmithingTable.getContainerId(); + + serverPlayer.connection.send(new ClientboundOpenScreenPacket(containerId, MenuType.SMITHING, message)); + serverPlayer.containerMenu = containerSmithingTable; + serverPlayer.initMenu(containerSmithingTable); + + return inventory; + } + + @Override + public void sendItems(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack[] items, + @Nullable org.bukkit.inventory.ItemStack cursor) { + NonNullList nmsItems = CustomInventoryUtil.convertToNMSItems(items); + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + ItemStack nmsCursor = CraftItemStack.asNMSCopy(cursor); + ServerPlayerConnection playerConnection = getPlayerConnection(serverPlayer); + + playerConnection.send(new ClientboundContainerSetContentPacket(containerId, state, nmsItems, nmsCursor)); + } + + @Override + public void sendFirstItem(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + ItemStack nmsItem = CraftItemStack.asNMSCopy(item); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(containerId, state, 0, nmsItem)); + } + + @Override + public void sendSecondItem(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + ItemStack nmsItem = CraftItemStack.asNMSCopy(item); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(containerId, state, 1, nmsItem)); + } + + @Override + public void sendResultItem(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + sendResultItem(player, CraftItemStack.asNMSCopy(item)); + } + + @Override + public void clearResultItem(@NotNull Player player) { + sendResultItem(player, ItemStack.EMPTY); + } + + @Override + public void setCursor(@NotNull Player player, @NotNull org.bukkit.inventory.ItemStack item) { + setCursor(player, CraftItemStack.asNMSCopy(item)); + } + + @Override + public void clearCursor(@NotNull Player player) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, ItemStack.EMPTY)); + } + + /** + * Sets the cursor of the given player + * + * @param player the player to set the cursor + * @param item the item to set the cursor to + * @since 0.10.18 + * @deprecated no longer used internally + */ + @Deprecated + private void setCursor(@NotNull Player player, @NotNull ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, item)); + } + + /** + * Sends the result item to the specified player with the given item + * + * @param player the player to send the result item to + * @param item the result item + * @since 0.10.18 + * @deprecated no longer used internally + */ + @Deprecated + private void sendResultItem(@NotNull Player player, @NotNull ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(containerId, state, 2, item)); + } + + /** + * Gets the container id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the container id for + * @return the container id + * @since 0.10.18 + * @deprecated no longer used internally + */ + @Contract(pure = true) + @Deprecated + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } + + /** + * Gets the player connection for the specified player + * + * @param serverPlayer the player to get the player connection from + * @return the player connection + * @since 0.10.18 + * @deprecated no longer used internally + */ + @NotNull + @Contract(pure = true) + @Deprecated + private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverPlayer) { + return serverPlayer.connection; + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * A custom container smithing table + * + * @since 0.10.18 + */ + private static class ContainerSmithingTableImpl extends SmithingMenu { + + /** + * Creates a new custom smithing table container for the specified player + * + * @param serverPlayer the player for whom this anvil container is + * @param title the title of the inventory + * @since 0.10.18 + */ + public ContainerSmithingTableImpl(@NotNull ServerPlayer serverPlayer, @NotNull Component title) { + super(serverPlayer.nextContainerCounter(), serverPlayer.getInventory(), + ContainerLevelAccess.create(serverPlayer.getCommandSenderWorld(), new BlockPos(0, 0, 0))); + + setTitle(title); + + this.checkReachable = false; + + Slot slotOne = this.slots.get(0); + Slot slotTwo = this.slots.get(1); + Slot slotThree = this.slots.get(2); + Slot slotFour = this.slots.get(3); + + this.slots.set(0, new Slot(slotOne.container, slotOne.index, slotOne.x, slotOne.y) { + @Override + public boolean mayPlace(@NotNull ItemStack stack) { + return true; + } + + @Override + public boolean mayPickup(net.minecraft.world.entity.player.@NotNull Player playerEntity) { + return true; + } + + @Override + public void onTake(net.minecraft.world.entity.player.@NotNull Player player, @NotNull ItemStack stack) { + slotOne.onTake(player, stack); + } + }); + + this.slots.set(1, new Slot(slotTwo.container, slotTwo.index, slotTwo.x, slotTwo.y) { + @Override + public boolean mayPlace(@NotNull ItemStack stack) { + return true; + } + + @Override + public boolean mayPickup(net.minecraft.world.entity.player.@NotNull Player playerEntity) { + return true; + } + + @Override + public void onTake(net.minecraft.world.entity.player.@NotNull Player player, @NotNull ItemStack stack) { + slotTwo.onTake(player, stack); + } + }); + + this.slots.set(2, new Slot(slotThree.container, slotThree.index, slotThree.x, slotThree.y) { + @Override + public boolean mayPlace(@NotNull ItemStack stack) { + return true; + } + + @Override + public boolean mayPickup(net.minecraft.world.entity.player.@NotNull Player playerEntity) { + return true; + } + + @Override + public void onTake(net.minecraft.world.entity.player.@NotNull Player player, @NotNull ItemStack stack) { + slotThree.onTake(player, stack); + } + }); + + this.slots.set(3, new Slot(slotFour.container, slotFour.index, slotFour.x, slotFour.y) { + @Override + public boolean mayPlace(@NotNull ItemStack stack) { + return true; + } + + @Override + public boolean mayPickup(net.minecraft.world.entity.player.@NotNull Player playerEntity) { + return true; + } + + @Override + public void onTake(net.minecraft.world.entity.player.@NotNull Player player, @NotNull ItemStack stack) { + slotFour.onTake(player, stack); + } + }); + } + + @Contract(pure = true, value = "_ -> true") + @Override + public boolean stillValid(@Nullable net.minecraft.world.entity.player.Player nmsPlayer) { + return true; + } + + @Override + public void slotsChanged(Container container) {} + + @Override + public void removed(net.minecraft.world.entity.player.Player nmsPlayer) {} + + @Override + public void createResult() {} + + @Override + protected void onTake(net.minecraft.world.entity.player.Player player, ItemStack stack) {} + + @Override + protected boolean mayPickup(net.minecraft.world.entity.player.Player player, boolean present) { + return true; + } + + public int getContainerId() { + return this.containerId; + } + } +} diff --git a/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/StonecutterInventoryImpl.java b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/StonecutterInventoryImpl.java new file mode 100644 index 00000000..85f43a7e --- /dev/null +++ b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/StonecutterInventoryImpl.java @@ -0,0 +1,222 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_1; + +import com.github.stefvanschie.inventoryframework.abstraction.StonecutterInventory; +import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; +import com.github.stefvanschie.inventoryframework.nms.v1_21_1.util.TextHolderUtil; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerPlayerConnection; +import net.minecraft.world.Container; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.StonecutterMenu; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryStonecutter; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_21_R1.inventory.view.CraftStonecutterView; +import org.bukkit.entity.Player; +import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.reflect.Field; + +/** + * Internal stonecutter inventory for 1.21.1 + * + * @since 0.10.18 + */ +public class StonecutterInventoryImpl extends StonecutterInventory { + + public StonecutterInventoryImpl(@NotNull InventoryHolder inventoryHolder) { + super(inventoryHolder); + } + + @Override + public void openInventory(@NotNull Player player, @NotNull TextHolder title, + @Nullable org.bukkit.inventory.ItemStack[] items) { + int itemAmount = items.length; + + if (itemAmount != 2) { + throw new IllegalArgumentException( + "The amount of items for a stonecutter should be 2, but is '" + itemAmount + "'" + ); + } + + ServerPlayer serverPlayer = getServerPlayer(player); + Component message = TextHolderUtil.toComponent(title); + ContainerStonecutterImpl containerEnchantmentTable = new ContainerStonecutterImpl(serverPlayer, items, message); + + serverPlayer.containerMenu = containerEnchantmentTable; + + int id = containerEnchantmentTable.containerId; + ClientboundOpenScreenPacket packet = new ClientboundOpenScreenPacket(id, MenuType.STONECUTTER, message); + + serverPlayer.connection.send(packet); + + sendItems(player, items); + } + + @Override + public void sendItems(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack[] items) { + NonNullList nmsItems = NonNullList.of( + ItemStack.EMPTY, + CraftItemStack.asNMSCopy(items[0]), + CraftItemStack.asNMSCopy(items[1]) + ); + + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + ItemStack cursor = CraftItemStack.asNMSCopy(player.getItemOnCursor()); + ServerPlayerConnection playerConnection = getPlayerConnection(serverPlayer); + + playerConnection.send(new ClientboundContainerSetContentPacket(containerId, state, nmsItems, cursor)); + } + + @Override + public void clearCursor(@NotNull Player player) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, ItemStack.EMPTY)); + } + + /** + * Gets the container id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the container id for + * @return the container id + * @since 0.10.18 + */ + @Contract(pure = true) + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } + + /** + * Gets the player connection for the specified player + * + * @param serverPlayer the player to get the player connection from + * @return the player connection + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverPlayer) { + return serverPlayer.connection; + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * A custom container enchanting table + * + * @since 0.10.18 + */ + private class ContainerStonecutterImpl extends StonecutterMenu { + + /** + * The player for this enchanting table container + */ + @NotNull + private final Player player; + + /** + * The internal bukkit entity for this container enchanting table + */ + @Nullable + private CraftStonecutterView bukkitEntity; + + /** + * Field for accessing the result inventory field + */ + @NotNull + private final Field resultContainerField; + + public ContainerStonecutterImpl(@NotNull ServerPlayer entityPlayer, + @Nullable org.bukkit.inventory.ItemStack[] items, @NotNull Component title) { + super(entityPlayer.nextContainerCounter(), entityPlayer.getInventory()); + + this.player = entityPlayer.getBukkitEntity(); + + setTitle(title); + + try { + //noinspection JavaReflectionMemberAccess + this.resultContainerField = StonecutterMenu.class.getDeclaredField("A"); //resultContainer + this.resultContainerField.setAccessible(true); + } catch (NoSuchFieldException exception) { + throw new RuntimeException(exception); + } + + container.setItem(0, CraftItemStack.asNMSCopy(items[0])); + getResultInventory().setItem(0, CraftItemStack.asNMSCopy(items[1])); + } + + @NotNull + @Override + public CraftStonecutterView getBukkitView() { + if (bukkitEntity == null) { + org.bukkit.inventory.StonecutterInventory inventory = new CraftInventoryStonecutter( + this.container, getResultInventory() + ) { + @NotNull + @Contract(pure = true) + @Override + public InventoryHolder getHolder() { + return inventoryHolder; + } + }; + + this.bukkitEntity = new CraftStonecutterView(player, inventory, this); + } + + return bukkitEntity; + } + + @Contract(pure = true, value = "_ -> true") + @Override + public boolean stillValid(@Nullable net.minecraft.world.entity.player.Player nmsPlayer) { + return true; + } + + @Override + public void slotsChanged(Container container) {} + + @Override + public void removed(net.minecraft.world.entity.player.Player nmsPlayer) {} + + /** + * Gets the result inventory + * + * @return the result inventory + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + public Container getResultInventory() { + try { + return (Container) resultContainerField.get(this); + } catch (IllegalAccessException exception) { + throw new RuntimeException(exception); + } + } + } +} diff --git a/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/util/CustomInventoryUtil.java b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/util/CustomInventoryUtil.java new file mode 100644 index 00000000..e1d0af6d --- /dev/null +++ b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/util/CustomInventoryUtil.java @@ -0,0 +1,41 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_1.util; + +import net.minecraft.core.NonNullList; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A utility class for custom inventories + * + * @since 0.10.18 + */ +public final class CustomInventoryUtil { + + /** + * A private constructor to prevent construction. + */ + private CustomInventoryUtil() {} + + /** + * Converts an array of Bukkit items into a non-null list of NMS items. The returned list is modifiable. If no items + * were specified, this returns an empty list. + * + * @param items the items to convert + * @return a list of converted items + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + public static NonNullList convertToNMSItems(@Nullable org.bukkit.inventory.ItemStack @NotNull [] items) { + NonNullList nmsItems = NonNullList.create(); + + for (org.bukkit.inventory.ItemStack item : items) { + nmsItems.add(CraftItemStack.asNMSCopy(item)); + } + + return nmsItems; + } +} diff --git a/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/util/TextHolderUtil.java b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/util/TextHolderUtil.java new file mode 100644 index 00000000..16d0416f --- /dev/null +++ b/nms/1_21_1/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_1/util/TextHolderUtil.java @@ -0,0 +1,67 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_1.util; + +import com.github.stefvanschie.inventoryframework.adventuresupport.ComponentHolder; +import com.github.stefvanschie.inventoryframework.adventuresupport.StringHolder; +import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; +import net.minecraft.core.HolderLookup; +import net.minecraft.network.chat.Component; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; +import java.util.stream.Stream; + +/** + * A utility class for adding {@link TextHolder} support. + * + * @since 0.10.18 + */ +public final class TextHolderUtil { + + private TextHolderUtil() { + //private constructor to prevent construction + } + + /** + * Converts the specified value to a vanilla component. + * + * @param holder the value to convert + * @return the value as a vanilla component + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + public static Component toComponent(@NotNull TextHolder holder) { + if (holder instanceof StringHolder) { + return toComponent((StringHolder) holder); + } else { + return toComponent((ComponentHolder) holder); + } + } + + /** + * Converts the specified legacy string holder to a vanilla component. + * + * @param holder the value to convert + * @return the value as a vanilla component + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private static Component toComponent(@NotNull StringHolder holder) { + return Component.literal(holder.asLegacyString()); + } + + /** + * Converts the specified Adventure component holder to a vanilla component. + * + * @param holder the value to convert + * @return the value as a vanilla component + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private static Component toComponent(@NotNull ComponentHolder holder) { + return Objects.requireNonNull(Component.Serializer.fromJson(holder.asJson(), HolderLookup.Provider.create(Stream.empty()))); + } +} diff --git a/nms/abstraction/pom.xml b/nms/abstraction/pom.xml index 1e7aa466..96032f6a 100644 --- a/nms/abstraction/pom.xml +++ b/nms/abstraction/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.17 + 0.10.18-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index 3ac4df64..f34a6e70 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,8 @@ IF nms/abstraction - nms/1_21 + nms/1_21_1 + nms/1_21_0 nms/1_20_6 nms/1_20_5 nms/1_20_3-4 @@ -45,7 +46,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.17 + 0.10.18-SNAPSHOT pom IF From 140822714f467dde838607ff8c47a2f27d50ca61 Mon Sep 17 00:00:00 2001 From: stefvanschie Date: Thu, 24 Oct 2024 21:40:39 +0200 Subject: [PATCH 34/40] Add 1.21.2 support --- .github/workflows/auto-deploy.yml | 19 + .github/workflows/maven.yml | 19 + IF/pom.xml | 6 + .../util/version/Version.java | 15 +- .../util/version/VersionMatcher.java | 16 + nms/1_21_2/pom.xml | 72 ++++ .../nms/v1_21_2/AnvilInventoryImpl.java | 284 +++++++++++++++ .../nms/v1_21_2/BeaconInventoryImpl.java | 201 +++++++++++ .../CartographyTableInventoryImpl.java | 218 ++++++++++++ .../v1_21_2/EnchantingTableInventoryImpl.java | 220 ++++++++++++ .../nms/v1_21_2/GrindstoneInventoryImpl.java | 208 +++++++++++ .../nms/v1_21_2/MerchantInventoryImpl.java | 118 ++++++ .../v1_21_2/SmithingTableInventoryImpl.java | 335 ++++++++++++++++++ .../nms/v1_21_2/StonecutterInventoryImpl.java | 222 ++++++++++++ .../nms/v1_21_2/util/CustomInventoryUtil.java | 41 +++ .../nms/v1_21_2/util/TextHolderUtil.java | 67 ++++ pom.xml | 1 + 17 files changed, 2059 insertions(+), 3 deletions(-) create mode 100644 nms/1_21_2/pom.xml create mode 100644 nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/AnvilInventoryImpl.java create mode 100644 nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/BeaconInventoryImpl.java create mode 100644 nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/CartographyTableInventoryImpl.java create mode 100644 nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/EnchantingTableInventoryImpl.java create mode 100644 nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/GrindstoneInventoryImpl.java create mode 100644 nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/MerchantInventoryImpl.java create mode 100644 nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/SmithingTableInventoryImpl.java create mode 100644 nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/StonecutterInventoryImpl.java create mode 100644 nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/util/CustomInventoryUtil.java create mode 100644 nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/util/TextHolderUtil.java diff --git a/.github/workflows/auto-deploy.yml b/.github/workflows/auto-deploy.yml index 08de3d9a..9c671e5b 100644 --- a/.github/workflows/auto-deploy.yml +++ b/.github/workflows/auto-deploy.yml @@ -124,6 +124,25 @@ jobs: java -jar BuildTools.jar --remapped --disable-java-check --dont-update java -jar BuildTools.jar --rev 1.21.1 --remapped --disable-java-check + + cd Bukkit + git checkout 8ec77750aa334e886ed2a0cee3320c62985b28e3 + cd .. + + cd CraftBukkit + git checkout d50f50585eab860db7889b3e736a62faf430f7a4 + cd .. + + cd Spigot + git checkout a084d85da8604d468f81091f56dc81166d912931 + cd .. + + cd BuildData + git checkout 0ea6fcc9bc8ad9e7c729f5031123bcc69ce2b033 + cd .. + + java -jar BuildTools.jar --remapped --disable-java-check --dont-update + cd ../ - name: Setup GPG keys run: cat <(echo -e "${{ secrets.GPG_KEY }}") | gpg --batch --import diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 222b4f84..1608ec05 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -130,6 +130,25 @@ jobs: java -jar BuildTools.jar --remapped --disable-java-check --dont-update java -jar BuildTools.jar --rev 1.21.1 --remapped --disable-java-check + + cd Bukkit + git checkout 8ec77750aa334e886ed2a0cee3320c62985b28e3 + cd .. + + cd CraftBukkit + git checkout d50f50585eab860db7889b3e736a62faf430f7a4 + cd .. + + cd Spigot + git checkout a084d85da8604d468f81091f56dc81166d912931 + cd .. + + cd BuildData + git checkout 0ea6fcc9bc8ad9e7c729f5031123bcc69ce2b033 + cd .. + + java -jar BuildTools.jar --remapped --disable-java-check --dont-update + cd ../ - name: Build with Maven run: mvn -B package --file pom.xml diff --git a/IF/pom.xml b/IF/pom.xml index 94636687..b88c7040 100644 --- a/IF/pom.xml +++ b/IF/pom.xml @@ -179,6 +179,12 @@ ${project.version} compile + + com.github.stefvanschie.inventoryframework + 1_21_2 + ${project.version} + compile + com.github.stefvanschie.inventoryframework iv-abstraction diff --git a/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/Version.java b/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/Version.java index 1838a62a..fab2b06e 100644 --- a/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/Version.java +++ b/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/Version.java @@ -175,7 +175,14 @@ public enum Version { * * @since 0.10.18 */ - V1_21_1; + V1_21_1, + + /** + * Version 1.21.2 + * + * @since 0.10.18 + */ + V1_21_2; /** * A collection of versions on which modern smithing tables are available. @@ -183,7 +190,7 @@ public enum Version { private static final Collection MODERN_SMITHING_TABLE_VERSIONS = EnumSet.of( V1_19_4, V1_20_0, V1_20_1, V1_20_2, V1_20_3_4, V1_20_5, V1_20_6, - V1_21_0, V1_21_1 + V1_21_0, V1_21_1, V1_21_2 ); /** @@ -204,7 +211,7 @@ public enum Version { */ @NotNull private static final Collection<@NotNull Version> INTERFACE_INVENTORY_VIEW = EnumSet.of( - V1_21_0, V1_21_1 + V1_21_0, V1_21_1, V1_21_2 ); /** @@ -307,6 +314,8 @@ public static Version getVersion() { return V1_21_0; case "1.21.1": return V1_21_1; + case "1.21.2": + return V1_21_2; default: throw new UnsupportedVersionException("The server version provided is not supported"); } diff --git a/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/VersionMatcher.java b/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/VersionMatcher.java index 331e7c01..63f7c8b7 100644 --- a/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/VersionMatcher.java +++ b/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/VersionMatcher.java @@ -321,6 +321,8 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.AnvilInventoryImpl.class); ANVIL_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.AnvilInventoryImpl.class); + ANVIL_INVENTORIES.put(Version.V1_21_2, + com.github.stefvanschie.inventoryframework.nms.v1_21_2.AnvilInventoryImpl.class); BEACON_INVENTORIES = new EnumMap<>(Version.class); BEACON_INVENTORIES.put(Version.V1_14, @@ -369,6 +371,8 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.BeaconInventoryImpl.class); BEACON_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.BeaconInventoryImpl.class); + BEACON_INVENTORIES.put(Version.V1_21_2, + com.github.stefvanschie.inventoryframework.nms.v1_21_2.BeaconInventoryImpl.class); CARTOGRAPHY_TABLE_INVENTORIES = new EnumMap<>(Version.class); CARTOGRAPHY_TABLE_INVENTORIES.put(Version.V1_14, @@ -417,6 +421,8 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.CartographyTableInventoryImpl.class); CARTOGRAPHY_TABLE_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.CartographyTableInventoryImpl.class); + CARTOGRAPHY_TABLE_INVENTORIES.put(Version.V1_21_2, + com.github.stefvanschie.inventoryframework.nms.v1_21_2.CartographyTableInventoryImpl.class); ENCHANTING_TABLE_INVENTORIES = new EnumMap<>(Version.class); ENCHANTING_TABLE_INVENTORIES.put(Version.V1_14, @@ -465,6 +471,8 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.EnchantingTableInventoryImpl.class); ENCHANTING_TABLE_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.EnchantingTableInventoryImpl.class); + ENCHANTING_TABLE_INVENTORIES.put(Version.V1_21_2, + com.github.stefvanschie.inventoryframework.nms.v1_21_2.EnchantingTableInventoryImpl.class); GRINDSTONE_INVENTORIES = new EnumMap<>(Version.class); GRINDSTONE_INVENTORIES.put(Version.V1_14, @@ -513,6 +521,8 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.GrindstoneInventoryImpl.class); GRINDSTONE_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.GrindstoneInventoryImpl.class); + GRINDSTONE_INVENTORIES.put(Version.V1_21_2, + com.github.stefvanschie.inventoryframework.nms.v1_21_2.GrindstoneInventoryImpl.class); MERCHANT_INVENTORIES = new EnumMap<>(Version.class); MERCHANT_INVENTORIES.put(Version.V1_14, @@ -561,6 +571,8 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.MerchantInventoryImpl.class); MERCHANT_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.MerchantInventoryImpl.class); + MERCHANT_INVENTORIES.put(Version.V1_21_2, + com.github.stefvanschie.inventoryframework.nms.v1_21_2.MerchantInventoryImpl.class); SMITHING_TABLE_INVENTORIES = new EnumMap<>(Version.class); SMITHING_TABLE_INVENTORIES.put(Version.V1_19_4, @@ -581,6 +593,8 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.SmithingTableInventoryImpl.class); SMITHING_TABLE_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.SmithingTableInventoryImpl.class); + SMITHING_TABLE_INVENTORIES.put(Version.V1_21_2, + com.github.stefvanschie.inventoryframework.nms.v1_21_2.SmithingTableInventoryImpl.class); LEGACY_SMITHING_TABLE_INVENTORIES = new EnumMap<>(Version.class); LEGACY_SMITHING_TABLE_INVENTORIES.put(Version.V1_16_1, @@ -657,5 +671,7 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.StonecutterInventoryImpl.class); STONECUTTER_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.StonecutterInventoryImpl.class); + STONECUTTER_INVENTORIES.put(Version.V1_21_2, + com.github.stefvanschie.inventoryframework.nms.v1_21_2.StonecutterInventoryImpl.class); } } diff --git a/nms/1_21_2/pom.xml b/nms/1_21_2/pom.xml new file mode 100644 index 00000000..943aabb8 --- /dev/null +++ b/nms/1_21_2/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + + com.github.stefvanschie.inventoryframework + IF-parent + 0.10.18-SNAPSHOT + ../../pom.xml + + + 1_21_2 + + + true + + + + + com.github.stefvanschie.inventoryframework + abstraction + ${project.version} + compile + + + org.spigotmc + spigot + 1.21.2-R0.1-SNAPSHOT + remapped-mojang + provided + + + + + + + net.md-5 + specialsource-maven-plugin + 2.0.3 + + + package + + remap + + remap-obf + + org.spigotmc:minecraft-server:1.21.2-R0.1-SNAPSHOT:txt:maps-mojang + true + org.spigotmc:spigot:1.21.2-R0.1-SNAPSHOT:jar:remapped-mojang + true + remapped-obf + + + + package + + remap + + remap-spigot + + ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + org.spigotmc:minecraft-server:1.21.2-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.21.2-R0.1-SNAPSHOT:jar:remapped-obf + + + + + + + \ No newline at end of file diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/AnvilInventoryImpl.java b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/AnvilInventoryImpl.java new file mode 100644 index 00000000..ad7e2de9 --- /dev/null +++ b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/AnvilInventoryImpl.java @@ -0,0 +1,284 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_2; + +import com.github.stefvanschie.inventoryframework.abstraction.AnvilInventory; +import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.TextHolderUtil; +import net.minecraft.core.BlockPos; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerPlayerConnection; +import net.minecraft.world.Container; +import net.minecraft.world.inventory.AnvilMenu; +import net.minecraft.world.inventory.ContainerLevelAccess; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R2.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Internal anvil inventory for 1.21.2 + * + * @since 0.10.18 + */ +public class AnvilInventoryImpl extends AnvilInventory { + + public AnvilInventoryImpl(@NotNull InventoryHolder inventoryHolder) { + super(inventoryHolder); + } + + @Override + public Inventory openInventory(@NotNull Player player, @NotNull TextHolder title, + @Nullable org.bukkit.inventory.ItemStack[] items) { + int itemAmount = items.length; + + if (itemAmount != 3) { + throw new IllegalArgumentException( + "The amount of items for an anvil should be 3, but is '" + itemAmount + "'" + ); + } + + ServerPlayer serverPlayer = getServerPlayer(player); + + //ignore deprecation: superseding method is only available on Paper + //noinspection deprecation + CraftEventFactory.handleInventoryCloseEvent(serverPlayer); + + serverPlayer.containerMenu = serverPlayer.inventoryMenu; + + Component message = TextHolderUtil.toComponent(title); + ContainerAnvilImpl containerAnvil = new ContainerAnvilImpl(serverPlayer, message); + + Inventory inventory = containerAnvil.getBukkitView().getTopInventory(); + + inventory.setItem(0, items[0]); + inventory.setItem(1, items[1]); + inventory.setItem(2, items[2]); + + int containerId = containerAnvil.getContainerId(); + + serverPlayer.connection.send(new ClientboundOpenScreenPacket(containerId, MenuType.ANVIL, message)); + serverPlayer.containerMenu = containerAnvil; + serverPlayer.initMenu(containerAnvil); + + return inventory; + } + + @Override + public void sendItems(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack[] items) { + NonNullList nmsItems = CustomInventoryUtil.convertToNMSItems(items); + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + ItemStack cursor = CraftItemStack.asNMSCopy(player.getItemOnCursor()); + ServerPlayerConnection playerConnection = getPlayerConnection(serverPlayer); + + playerConnection.send(new ClientboundContainerSetContentPacket(containerId, state, nmsItems, cursor)); + } + + @Override + public void sendFirstItem(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + ItemStack nmsItem = CraftItemStack.asNMSCopy(item); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(containerId, state, 0, nmsItem)); + } + + @Override + public void sendSecondItem(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + ItemStack nmsItem = CraftItemStack.asNMSCopy(item); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(containerId, state, 1, nmsItem)); + } + + @Override + public void sendResultItem(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + sendResultItem(player, CraftItemStack.asNMSCopy(item)); + } + + @Override + public void clearResultItem(@NotNull Player player) { + sendResultItem(player, ItemStack.EMPTY); + } + + @Override + public void setCursor(@NotNull Player player, @NotNull org.bukkit.inventory.ItemStack item) { + setCursor(player, CraftItemStack.asNMSCopy(item)); + } + + @Override + public void clearCursor(@NotNull Player player) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, ItemStack.EMPTY)); + } + + /** + * Sets the cursor of the given player + * + * @param player the player to set the cursor + * @param item the item to set the cursor to + * @since 0.10.18 + * @deprecated no longer used internally + */ + @Deprecated + private void setCursor(@NotNull Player player, @NotNull ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, item)); + } + + /** + * Sends the result item to the specified player with the given item + * + * @param player the player to send the result item to + * @param item the result item + * @since 0.10.18 + * @deprecated no longer used internally + */ + @Deprecated + private void sendResultItem(@NotNull Player player, @NotNull ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(containerId, state, 2, item)); + } + + /** + * Gets the container id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the container id for + * @return the container id + * @since 0.10.18 + * @deprecated no longer used internally + */ + @Contract(pure = true) + @Deprecated + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } + + /** + * Gets the player connection for the specified player + * + * @param serverPlayer the player to get the player connection from + * @return the player connection + * @since 0.10.18 + * @deprecated no longer used internally + */ + @NotNull + @Contract(pure = true) + @Deprecated + private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverPlayer) { + return serverPlayer.connection; + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * A custom container anvil for responding to item renaming + * + * @since 0.10.18 + */ + private class ContainerAnvilImpl extends AnvilMenu { + + /** + * Creates a new custom anvil container for the specified player + * + * @param serverPlayer the player for whom this anvil container is + * @param title the title of the inventory + * @since 0.10.18 + */ + public ContainerAnvilImpl(@NotNull ServerPlayer serverPlayer, @NotNull Component title) { + super(serverPlayer.nextContainerCounter(), serverPlayer.getInventory(), + ContainerLevelAccess.create(serverPlayer.getCommandSenderWorld(), new BlockPos(0, 0, 0))); + + this.checkReachable = false; + this.cost.set(AnvilInventoryImpl.super.cost); + + setTitle(title); + + Slot originalSlot = this.slots.get(2); + + this.slots.set(2, new Slot(originalSlot.container, originalSlot.index, originalSlot.x, originalSlot.y) { + @Override + public boolean mayPlace(@NotNull ItemStack stack) { + return true; + } + + @Override + public boolean mayPickup(net.minecraft.world.entity.player.@NotNull Player playerEntity) { + return true; + } + + @Override + public void onTake(net.minecraft.world.entity.player.@NotNull Player player, @NotNull ItemStack stack) { + originalSlot.onTake(player, stack); + } + }); + } + + @Override + public boolean setItemName(@Nullable String name) { + name = name == null ? "" : name; + + /* Only update if the name is actually different. This may be called even if the name is not different, + particularly when putting an item in the first slot. */ + if (!name.equals(AnvilInventoryImpl.super.observableText.get())) { + AnvilInventoryImpl.super.observableText.set(name); + } + + //the client predicts the output result, so we broadcast the state again to override it + broadcastFullState(); + return true; //no idea what this is for + } + + @Override + public void createResult() {} + + @Override + public void removed(net.minecraft.world.entity.player.@NotNull Player nmsPlayer) {} + + @Override + protected void clearContainer(net.minecraft.world.entity.player.@NotNull Player player, + @NotNull Container inventory) {} + + @Override + protected void onTake(net.minecraft.world.entity.player.@NotNull Player player, @NotNull ItemStack stack) {} + + public int getContainerId() { + return this.containerId; + } + } +} diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/BeaconInventoryImpl.java b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/BeaconInventoryImpl.java new file mode 100644 index 00000000..c8ef5444 --- /dev/null +++ b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/BeaconInventoryImpl.java @@ -0,0 +1,201 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_2; + +import com.github.stefvanschie.inventoryframework.abstraction.BeaconInventory; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerPlayerConnection; +import net.minecraft.world.Container; +import net.minecraft.world.inventory.BeaconMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftInventoryBeacon; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_21_R2.inventory.view.CraftBeaconView; +import org.bukkit.entity.Player; +import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.reflect.Field; + +/** + * Internal beacon inventory for 1.21.2 + * + * @since 0.10.18 + */ +public class BeaconInventoryImpl extends BeaconInventory { + + public BeaconInventoryImpl(@NotNull InventoryHolder inventoryHolder) { + super(inventoryHolder); + } + + @Override + public void openInventory(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + ContainerBeaconImpl containerBeacon = new ContainerBeaconImpl(serverPlayer, item); + + serverPlayer.containerMenu = containerBeacon; + + int id = containerBeacon.containerId; + Component beacon = Component.literal("Beacon"); + + serverPlayer.connection.send(new ClientboundOpenScreenPacket(id, MenuType.BEACON, beacon)); + + sendItem(player, item); + } + + @Override + public void sendItem(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + NonNullList items = NonNullList.of( + ItemStack.EMPTY, //the first item doesn't count for some reason, so send a dummy item + CraftItemStack.asNMSCopy(item) + ); + + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + ItemStack cursor = CraftItemStack.asNMSCopy(player.getItemOnCursor()); + ServerPlayerConnection playerConnection = getPlayerConnection(serverPlayer); + + playerConnection.send(new ClientboundContainerSetContentPacket(containerId, state, items, cursor)); + } + + @Override + public void clearCursor(@NotNull Player player) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, ItemStack.EMPTY)); + } + + /** + * Gets the container id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the container id for + * @return the container id + * @since 0.10.18 + */ + @Contract(pure = true) + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } + + /** + * Gets the player connection for the specified player + * + * @param serverPlayer the player to get the player connection from + * @return the player connection + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverPlayer) { + return serverPlayer.connection; + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * A custom container beacon + * + * @since 0.10.18 + */ + private class ContainerBeaconImpl extends BeaconMenu { + + /** + * The player for this beacon container + */ + @NotNull + private final Player player; + + /** + * The internal bukkit entity for this container beacon + */ + @Nullable + private CraftBeaconView bukkitEntity; + + /** + * Field for accessing the beacon field + */ + @NotNull + private final Field beaconField; + + public ContainerBeaconImpl(@NotNull ServerPlayer serverPlayer, @Nullable org.bukkit.inventory.ItemStack item) { + super(serverPlayer.nextContainerCounter(), serverPlayer.getInventory()); + + this.player = serverPlayer.getBukkitEntity(); + setTitle(Component.empty()); + + try { + //noinspection JavaReflectionMemberAccess + this.beaconField = BeaconMenu.class.getDeclaredField("u"); //beacon + this.beaconField.setAccessible(true); + } catch (NoSuchFieldException exception) { + throw new RuntimeException(exception); + } + + try { + ItemStack itemStack = CraftItemStack.asNMSCopy(item); + + ((Container) beaconField.get(this)).setItem(0, itemStack); + } catch (IllegalAccessException exception) { + throw new RuntimeException(exception); + } + } + + @NotNull + @Override + public CraftBeaconView getBukkitView() { + if (bukkitEntity == null) { + try { + Container container = (Container) beaconField.get(this); + + org.bukkit.inventory.BeaconInventory inventory = new CraftInventoryBeacon(container) { + @NotNull + @Contract(pure = true) + @Override + public InventoryHolder getHolder() { + return inventoryHolder; + } + }; + + this.bukkitEntity = new CraftBeaconView(player, inventory, this); + } catch (IllegalAccessException exception) { + throw new RuntimeException(exception); + } + } + + return bukkitEntity; + } + + @Contract(pure = true, value = "_ -> true") + @Override + public boolean stillValid(@Nullable net.minecraft.world.entity.player.Player nmsPlayer) { + return true; + } + + @Override + public void slotsChanged(Container container) {} + + @Override + public void removed(net.minecraft.world.entity.player.Player nmsPlayer) {} + + } +} diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/CartographyTableInventoryImpl.java b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/CartographyTableInventoryImpl.java new file mode 100644 index 00000000..905f3ce8 --- /dev/null +++ b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/CartographyTableInventoryImpl.java @@ -0,0 +1,218 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_2; + +import com.github.stefvanschie.inventoryframework.abstraction.CartographyTableInventory; +import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.TextHolderUtil; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerPlayerConnection; +import net.minecraft.world.Container; +import net.minecraft.world.inventory.CartographyTableMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftInventory; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftInventoryCartography; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftInventoryView; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.reflect.Field; + +/** + * Internal cartography table inventory for 1.21.2 + * + * @since 0.10.18 + */ +public class CartographyTableInventoryImpl extends CartographyTableInventory { + + public CartographyTableInventoryImpl(@NotNull InventoryHolder inventoryHolder) { + super(inventoryHolder); + } + + @Override + public void openInventory(@NotNull Player player, @NotNull TextHolder title, + @Nullable org.bukkit.inventory.ItemStack[] items) { + int itemAmount = items.length; + + if (itemAmount != 3) { + throw new IllegalArgumentException( + "The amount of items for a cartography table should be 3, but is '" + itemAmount + "'" + ); + } + + + ServerPlayer serverPlayer = getServerPlayer(player); + Component message = TextHolderUtil.toComponent(title); + + ContainerCartographyTableImpl containerCartographyTable = new ContainerCartographyTableImpl( + serverPlayer, items, message + ); + + serverPlayer.containerMenu = containerCartographyTable; + + int id = containerCartographyTable.containerId; + + serverPlayer.connection.send(new ClientboundOpenScreenPacket(id, MenuType.CARTOGRAPHY_TABLE, message)); + + sendItems(player, items); + } + + @Override + public void sendItems(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack[] items) { + NonNullList nmsItems = CustomInventoryUtil.convertToNMSItems(items); + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + ItemStack cursor = CraftItemStack.asNMSCopy(player.getItemOnCursor()); + ServerPlayerConnection playerConnection = getPlayerConnection(serverPlayer); + + playerConnection.send(new ClientboundContainerSetContentPacket(containerId, state, nmsItems, cursor)); + } + + @Override + public void clearCursor(@NotNull Player player) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, ItemStack.EMPTY)); + } + + /** + * Gets the container id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the container id for + * @return the container id + * @since 0.10.18 + */ + @Contract(pure = true) + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } + + /** + * Gets the player connection for the specified player + * + * @param serverPlayer the player to get the player connection from + * @return the player connection + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverPlayer) { + return serverPlayer.connection; + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * A custom container cartography table + * + * @since 0.10.18 + */ + private class ContainerCartographyTableImpl extends CartographyTableMenu { + + /** + * The player for this cartography table container + */ + @NotNull + private final Player player; + + /** + * The internal bukkit entity for this container cartography table + */ + @Nullable + private CraftInventoryView bukkitEntity; + + /** + * Field for accessing the result inventory field + */ + @NotNull + private final Field resultContainerField; + + public ContainerCartographyTableImpl(@NotNull ServerPlayer serverPlayer, + @Nullable org.bukkit.inventory.ItemStack[] items, + @NotNull Component title) { + super(serverPlayer.nextContainerCounter(), serverPlayer.getInventory()); + + this.player = serverPlayer.getBukkitEntity(); + + setTitle(title); + + try { + //noinspection JavaReflectionMemberAccess + this.resultContainerField = CartographyTableMenu.class.getDeclaredField("w"); //resultContainer + this.resultContainerField.setAccessible(true); + } catch (NoSuchFieldException exception) { + throw new RuntimeException(exception); + } + + container.setItem(0, CraftItemStack.asNMSCopy(items[0])); + container.setItem(1, CraftItemStack.asNMSCopy(items[1])); + + getResultInventory().setItem(0, CraftItemStack.asNMSCopy(items[2])); + } + + @NotNull + @Override + public CraftInventoryView getBukkitView() { + if (bukkitEntity == null) { + CraftInventory inventory = new CraftInventoryCartography(super.container, getResultInventory()) { + @NotNull + @Contract(pure = true) + @Override + public InventoryHolder getHolder() { + return inventoryHolder; + } + }; + + bukkitEntity = new CraftInventoryView(player, inventory, this); + } + + return bukkitEntity; + } + + @Contract(pure = true, value = "_ -> true") + @Override + public boolean stillValid(@Nullable net.minecraft.world.entity.player.Player nmsPlayer) { + return true; + } + + @Override + public void slotsChanged(Container container) {} + + @Override + public void removed(net.minecraft.world.entity.player.Player nmsPlayer) {} + + @NotNull + @Contract(pure = true) + private Container getResultInventory() { + try { + return (Container) resultContainerField.get(this); + } catch (IllegalAccessException exception) { + throw new RuntimeException(exception); + } + } + + } +} diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/EnchantingTableInventoryImpl.java b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/EnchantingTableInventoryImpl.java new file mode 100644 index 00000000..8b9fab94 --- /dev/null +++ b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/EnchantingTableInventoryImpl.java @@ -0,0 +1,220 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_2; + +import com.github.stefvanschie.inventoryframework.abstraction.EnchantingTableInventory; +import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.TextHolderUtil; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerPlayerConnection; +import net.minecraft.world.Container; +import net.minecraft.world.inventory.EnchantmentMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftInventoryEnchanting; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_21_R2.inventory.view.CraftEnchantmentView; +import org.bukkit.entity.Player; +import org.bukkit.inventory.EnchantingInventory; +import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.reflect.Field; + +/** + * Internal enchanting table inventory for 1.21.2 + * + * @since 0.10.18 + */ +public class EnchantingTableInventoryImpl extends EnchantingTableInventory { + + public EnchantingTableInventoryImpl(@NotNull InventoryHolder inventoryHolder) { + super(inventoryHolder); + } + + @Override + public void openInventory(@NotNull Player player, @NotNull TextHolder title, + @Nullable org.bukkit.inventory.ItemStack[] items) { + int itemAmount = items.length; + + if (itemAmount != 2) { + throw new IllegalArgumentException( + "The amount of items for an enchanting table should be 2, but is '" + itemAmount + "'" + ); + } + + ServerPlayer serverPlayer = getServerPlayer(player); + Component message = TextHolderUtil.toComponent(title); + ContainerEnchantingTableImpl containerEnchantmentTable = new ContainerEnchantingTableImpl( + serverPlayer, items, message + ); + + serverPlayer.containerMenu = containerEnchantmentTable; + + int id = containerEnchantmentTable.containerId; + + serverPlayer.connection.send(new ClientboundOpenScreenPacket(id, MenuType.ENCHANTMENT, message)); + + sendItems(player, items); + } + + @Override + public void sendItems(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack[] items) { + NonNullList nmsItems = NonNullList.of( + ItemStack.EMPTY, + CraftItemStack.asNMSCopy(items[0]), + CraftItemStack.asNMSCopy(items[1]) + ); + + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + ItemStack cursor = CraftItemStack.asNMSCopy(player.getItemOnCursor()); + ServerPlayerConnection playerConnection = getPlayerConnection(serverPlayer); + + playerConnection.send(new ClientboundContainerSetContentPacket(containerId, state, nmsItems, cursor)); + } + + @Override + public void clearCursor(@NotNull Player player) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, ItemStack.EMPTY)); + } + + /** + * Gets the containerId id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the containerId id for + * @return the containerId id + * @since 0.10.18 + */ + @Contract(pure = true) + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } + + /** + * Gets the player connection for the specified player + * + * @param serverPlayer the player to get the player connection from + * @return the player connection + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverPlayer) { + return serverPlayer.connection; + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * A custom container enchanting table + * + * @since 0.10.18 + */ + private class ContainerEnchantingTableImpl extends EnchantmentMenu { + + /** + * The player for this enchanting table container + */ + @NotNull + private final Player player; + + /** + * The internal bukkit entity for this container enchanting table + */ + @Nullable + private CraftEnchantmentView bukkitEntity; + + /** + * Field for accessing the enchant slots field + */ + @NotNull + private final Field enchantSlotsField; + + public ContainerEnchantingTableImpl(@NotNull ServerPlayer serverPlayer, + @Nullable org.bukkit.inventory.ItemStack[] items, + @NotNull Component title) { + super(serverPlayer.nextContainerCounter(), serverPlayer.getInventory()); + + this.player = serverPlayer.getBukkitEntity(); + + setTitle(title); + + try { + //noinspection JavaReflectionMemberAccess + this.enchantSlotsField = EnchantmentMenu.class.getDeclaredField("q"); //enchantSlots + this.enchantSlotsField.setAccessible(true); + } catch (NoSuchFieldException exception) { + throw new RuntimeException(exception); + } + + try { + Container input = (Container) enchantSlotsField.get(this); + + input.setItem(0, CraftItemStack.asNMSCopy(items[0])); + input.setItem(1, CraftItemStack.asNMSCopy(items[1])); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + + @NotNull + @Override + public CraftEnchantmentView getBukkitView() { + if (bukkitEntity == null) { + try { + Container container = (Container) enchantSlotsField.get(this); + + EnchantingInventory inventory = new CraftInventoryEnchanting(container) { + @NotNull + @Contract(pure = true) + @Override + public InventoryHolder getHolder() { + return inventoryHolder; + } + }; + + this.bukkitEntity = new CraftEnchantmentView(player, inventory, this); + } catch (IllegalAccessException exception) { + exception.printStackTrace(); + } + } + + return bukkitEntity; + } + + @Contract(pure = true, value = "_ -> true") + @Override + public boolean stillValid(@Nullable net.minecraft.world.entity.player.Player nmsPlayer) { + return true; + } + + @Override + public void slotsChanged(Container container) {} + + @Override + public void removed(net.minecraft.world.entity.player.Player nmsPlayer) {} + + } +} diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/GrindstoneInventoryImpl.java b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/GrindstoneInventoryImpl.java new file mode 100644 index 00000000..da238f42 --- /dev/null +++ b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/GrindstoneInventoryImpl.java @@ -0,0 +1,208 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_2; + +import com.github.stefvanschie.inventoryframework.abstraction.GrindstoneInventory; +import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.TextHolderUtil; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerPlayerConnection; +import net.minecraft.world.Container; +import net.minecraft.world.inventory.GrindstoneMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R2.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Internal grindstone inventory for 1.21.1 + * + * @since 0.10.18 + */ +public class GrindstoneInventoryImpl extends GrindstoneInventory { + + public GrindstoneInventoryImpl(@NotNull InventoryHolder inventoryHolder) { + super(inventoryHolder); + } + + @Override + public Inventory openInventory(@NotNull Player player, @NotNull TextHolder title, + @Nullable org.bukkit.inventory.ItemStack[] items) { + int itemAmount = items.length; + + if (itemAmount != 3) { + throw new IllegalArgumentException( + "The amount of items for a grindstone should be 3, but is '" + itemAmount + "'" + ); + } + + ServerPlayer serverPlayer = getServerPlayer(player); + + //ignore deprecation: superseding method is only available on Paper + //noinspection deprecation + CraftEventFactory.handleInventoryCloseEvent(serverPlayer); + + serverPlayer.containerMenu = serverPlayer.inventoryMenu; + + Component message = TextHolderUtil.toComponent(title); + ContainerGrindstoneImpl containerGrindstone = new ContainerGrindstoneImpl(serverPlayer, message); + + Inventory inventory = containerGrindstone.getBukkitView().getTopInventory(); + + inventory.setItem(0, items[0]); + inventory.setItem(1, items[1]); + inventory.setItem(2, items[2]); + + int containerId = containerGrindstone.getContainerId(); + + serverPlayer.connection.send(new ClientboundOpenScreenPacket(containerId, MenuType.GRINDSTONE, message)); + serverPlayer.containerMenu = containerGrindstone; + serverPlayer.initMenu(containerGrindstone); + + return inventory; + } + + @Override + public void sendItems(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack[] items, + @Nullable org.bukkit.inventory.ItemStack cursor) { + if (cursor == null) { + throw new IllegalArgumentException("Cursor may not be null on version 1.19.2"); + } + + NonNullList nmsItems = CustomInventoryUtil.convertToNMSItems(items); + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + ItemStack nmsCursor = CraftItemStack.asNMSCopy(cursor); + ServerPlayerConnection playerConnection = getPlayerConnection(serverPlayer); + + playerConnection.send(new ClientboundContainerSetContentPacket(containerId, state, nmsItems, nmsCursor)); + } + + @Override + public void clearCursor(@NotNull Player player) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, ItemStack.EMPTY)); + } + + /** + * Gets the containerId id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the containerId id for + * @return the containerId id + * @since 0.10.18 + * @deprecated no longer used internally + */ + @Contract(pure = true) + @Deprecated + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } + + /** + * Gets the player connection for the specified player + * + * @param serverPlayer the player to get the player connection from + * @return the player connection + * @since 0.10.18 + * @deprecated no longer used internally + */ + @NotNull + @Contract(pure = true) + @Deprecated + private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverPlayer) { + return serverPlayer.connection; + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * A custom container grindstone + * + * @since 0.10.18 + */ + private static class ContainerGrindstoneImpl extends GrindstoneMenu { + + /** + * Creates a new grindstone container + * + * @param serverPlayer the player for whom this container should be opened + * @param title the title of the gui + * @since 0.10.18 + */ + public ContainerGrindstoneImpl(@NotNull ServerPlayer serverPlayer, @NotNull Component title) { + super(serverPlayer.nextContainerCounter(), serverPlayer.getInventory()); + + setTitle(title); + + Slot firstSlot = this.slots.get(0); + Slot secondSlot = this.slots.get(1); + Slot thirdSlot = this.slots.get(2); + + this.slots.set(0, new Slot(firstSlot.container, firstSlot.index, firstSlot.x, firstSlot.y) { + @Override + public boolean mayPlace(ItemStack stack) { + return true; + } + }); + + this.slots.set(1, new Slot(secondSlot.container, secondSlot.index, secondSlot.x, secondSlot.y) { + @Override + public boolean mayPlace(ItemStack stack) { + return true; + } + }); + + this.slots.set(2, new Slot(thirdSlot.container, thirdSlot.index, thirdSlot.x, thirdSlot.y) { + @Override + public boolean mayPlace(ItemStack stack) { + return true; + } + + @Override + public void onTake(net.minecraft.world.entity.player.Player player, ItemStack stack) {} + }); + } + + @Contract(pure = true, value = "_ -> true") + @Override + public boolean stillValid(@Nullable net.minecraft.world.entity.player.Player nmsPlayer) { + return true; + } + + @Override + public void slotsChanged(Container container) {} + + @Override + public void removed(net.minecraft.world.entity.player.Player nmsPlayer) {} + + public int getContainerId() { + return this.containerId; + } + } +} diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/MerchantInventoryImpl.java b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/MerchantInventoryImpl.java new file mode 100644 index 00000000..4ce1393b --- /dev/null +++ b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/MerchantInventoryImpl.java @@ -0,0 +1,118 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_2; + +import com.github.stefvanschie.inventoryframework.abstraction.MerchantInventory; +import net.minecraft.core.component.DataComponentPredicate; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.trading.ItemCost; +import net.minecraft.world.item.trading.MerchantOffer; +import net.minecraft.world.item.trading.MerchantOffers; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.MerchantRecipe; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * Internal merchant inventory for 1.21.2 + * + * @since 0.10.18 + */ +public class MerchantInventoryImpl extends MerchantInventory { + + @Override + public void sendMerchantOffers(@NotNull Player player, + @NotNull List> trades, + int level, int experience) { + MerchantOffers offers = new MerchantOffers(); + + for (Map.Entry entry : trades) { + MerchantRecipe recipe = entry.getKey(); + List ingredients = recipe.getIngredients(); + + if (ingredients.size() < 1) { + throw new IllegalStateException("Merchant recipe has no ingredients"); + } + + ItemStack itemA = ingredients.get(0); + ItemStack itemB = null; + + if (ingredients.size() >= 2) { + itemB = ingredients.get(1); + } + + net.minecraft.world.item.ItemStack nmsItemA = CraftItemStack.asNMSCopy(itemA); + net.minecraft.world.item.ItemStack nmsItemB = net.minecraft.world.item.ItemStack.EMPTY; + net.minecraft.world.item.ItemStack nmsItemResult = CraftItemStack.asNMSCopy(recipe.getResult()); + + if (itemB != null) { + nmsItemB = CraftItemStack.asNMSCopy(itemB); + } + + ItemCost itemCostA = convertItemStackToItemCost(nmsItemA); + ItemCost itemCostB = convertItemStackToItemCost(nmsItemB); + + int uses = recipe.getUses(); + int maxUses = recipe.getMaxUses(); + int exp = recipe.getVillagerExperience(); + float multiplier = recipe.getPriceMultiplier(); + + MerchantOffer merchantOffer = new MerchantOffer( + itemCostA, Optional.of(itemCostB), nmsItemResult, uses, maxUses, exp, multiplier + ); + merchantOffer.setSpecialPriceDiff(entry.getValue()); + + offers.add(merchantOffer); + } + + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + + serverPlayer.sendMerchantOffers(containerId, offers, level, experience, true, false); + } + + /** + * Converts an NMS item stack to an item cost. + * + * @param itemStack the item stack to convert + * @return the item cost + * @since 0.10.18 + */ + @NotNull + @Contract(value = "_ -> new", pure = true) + private ItemCost convertItemStackToItemCost(@NotNull net.minecraft.world.item.ItemStack itemStack) { + DataComponentPredicate predicate = DataComponentPredicate.allOf(itemStack.getComponents()); + + return new ItemCost(itemStack.getItemHolder(), itemStack.getCount(), predicate, itemStack); + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * Gets the containerId id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the containerId id for + * @return the containerId id + * @since 0.10.18 + */ + @Contract(pure = true) + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } +} diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/SmithingTableInventoryImpl.java b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/SmithingTableInventoryImpl.java new file mode 100644 index 00000000..ddb5aeff --- /dev/null +++ b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/SmithingTableInventoryImpl.java @@ -0,0 +1,335 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_2; + +import com.github.stefvanschie.inventoryframework.abstraction.SmithingTableInventory; +import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.TextHolderUtil; +import net.minecraft.core.BlockPos; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerPlayerConnection; +import net.minecraft.world.Container; +import net.minecraft.world.inventory.ContainerLevelAccess; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.inventory.SmithingMenu; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R2.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Internal smithing table inventory for 1.21.2. This is only available for Minecraft 1.20 and higher. + * + * @since 0.10.18 + */ +public class SmithingTableInventoryImpl extends SmithingTableInventory { + + public SmithingTableInventoryImpl(@NotNull InventoryHolder inventoryHolder) { + super(inventoryHolder); + } + + @NotNull + @Override + public Inventory openInventory(@NotNull Player player, @NotNull TextHolder title, + @Nullable org.bukkit.inventory.ItemStack[] items) { + int itemAmount = items.length; + + if (itemAmount != 4) { + throw new IllegalArgumentException( + "The amount of items for a smithing table should be 4, but is '" + itemAmount + "'" + ); + } + + ServerPlayer serverPlayer = getServerPlayer(player); + + //ignore deprecation: superseding method is only available on Paper + //noinspection deprecation + CraftEventFactory.handleInventoryCloseEvent(serverPlayer); + + serverPlayer.containerMenu = serverPlayer.inventoryMenu; + + Component message = TextHolderUtil.toComponent(title); + ContainerSmithingTableImpl containerSmithingTable = new ContainerSmithingTableImpl(serverPlayer, message); + + Inventory inventory = containerSmithingTable.getBukkitView().getTopInventory(); + + inventory.setItem(0, items[0]); + inventory.setItem(1, items[1]); + inventory.setItem(2, items[2]); + inventory.setItem(3, items[3]); + + int containerId = containerSmithingTable.getContainerId(); + + serverPlayer.connection.send(new ClientboundOpenScreenPacket(containerId, MenuType.SMITHING, message)); + serverPlayer.containerMenu = containerSmithingTable; + serverPlayer.initMenu(containerSmithingTable); + + return inventory; + } + + @Override + public void sendItems(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack[] items, + @Nullable org.bukkit.inventory.ItemStack cursor) { + NonNullList nmsItems = CustomInventoryUtil.convertToNMSItems(items); + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + ItemStack nmsCursor = CraftItemStack.asNMSCopy(cursor); + ServerPlayerConnection playerConnection = getPlayerConnection(serverPlayer); + + playerConnection.send(new ClientboundContainerSetContentPacket(containerId, state, nmsItems, nmsCursor)); + } + + @Override + public void sendFirstItem(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + ItemStack nmsItem = CraftItemStack.asNMSCopy(item); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(containerId, state, 0, nmsItem)); + } + + @Override + public void sendSecondItem(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + ItemStack nmsItem = CraftItemStack.asNMSCopy(item); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(containerId, state, 1, nmsItem)); + } + + @Override + public void sendResultItem(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack item) { + sendResultItem(player, CraftItemStack.asNMSCopy(item)); + } + + @Override + public void clearResultItem(@NotNull Player player) { + sendResultItem(player, ItemStack.EMPTY); + } + + @Override + public void setCursor(@NotNull Player player, @NotNull org.bukkit.inventory.ItemStack item) { + setCursor(player, CraftItemStack.asNMSCopy(item)); + } + + @Override + public void clearCursor(@NotNull Player player) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, ItemStack.EMPTY)); + } + + /** + * Sets the cursor of the given player + * + * @param player the player to set the cursor + * @param item the item to set the cursor to + * @since 0.10.18 + * @deprecated no longer used internally + */ + @Deprecated + private void setCursor(@NotNull Player player, @NotNull ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, item)); + } + + /** + * Sends the result item to the specified player with the given item + * + * @param player the player to send the result item to + * @param item the result item + * @since 0.10.18 + * @deprecated no longer used internally + */ + @Deprecated + private void sendResultItem(@NotNull Player player, @NotNull ItemStack item) { + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(containerId, state, 2, item)); + } + + /** + * Gets the container id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the container id for + * @return the container id + * @since 0.10.18 + * @deprecated no longer used internally + */ + @Contract(pure = true) + @Deprecated + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } + + /** + * Gets the player connection for the specified player + * + * @param serverPlayer the player to get the player connection from + * @return the player connection + * @since 0.10.18 + * @deprecated no longer used internally + */ + @NotNull + @Contract(pure = true) + @Deprecated + private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverPlayer) { + return serverPlayer.connection; + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * A custom container smithing table + * + * @since 0.10.18 + */ + private static class ContainerSmithingTableImpl extends SmithingMenu { + + /** + * Creates a new custom smithing table container for the specified player + * + * @param serverPlayer the player for whom this anvil container is + * @param title the title of the inventory + * @since 0.10.18 + */ + public ContainerSmithingTableImpl(@NotNull ServerPlayer serverPlayer, @NotNull Component title) { + super(serverPlayer.nextContainerCounter(), serverPlayer.getInventory(), + ContainerLevelAccess.create(serverPlayer.getCommandSenderWorld(), new BlockPos(0, 0, 0))); + + setTitle(title); + + this.checkReachable = false; + + Slot slotOne = this.slots.get(0); + Slot slotTwo = this.slots.get(1); + Slot slotThree = this.slots.get(2); + Slot slotFour = this.slots.get(3); + + this.slots.set(0, new Slot(slotOne.container, slotOne.index, slotOne.x, slotOne.y) { + @Override + public boolean mayPlace(@NotNull ItemStack stack) { + return true; + } + + @Override + public boolean mayPickup(net.minecraft.world.entity.player.@NotNull Player playerEntity) { + return true; + } + + @Override + public void onTake(net.minecraft.world.entity.player.@NotNull Player player, @NotNull ItemStack stack) { + slotOne.onTake(player, stack); + } + }); + + this.slots.set(1, new Slot(slotTwo.container, slotTwo.index, slotTwo.x, slotTwo.y) { + @Override + public boolean mayPlace(@NotNull ItemStack stack) { + return true; + } + + @Override + public boolean mayPickup(net.minecraft.world.entity.player.@NotNull Player playerEntity) { + return true; + } + + @Override + public void onTake(net.minecraft.world.entity.player.@NotNull Player player, @NotNull ItemStack stack) { + slotTwo.onTake(player, stack); + } + }); + + this.slots.set(2, new Slot(slotThree.container, slotThree.index, slotThree.x, slotThree.y) { + @Override + public boolean mayPlace(@NotNull ItemStack stack) { + return true; + } + + @Override + public boolean mayPickup(net.minecraft.world.entity.player.@NotNull Player playerEntity) { + return true; + } + + @Override + public void onTake(net.minecraft.world.entity.player.@NotNull Player player, @NotNull ItemStack stack) { + slotThree.onTake(player, stack); + } + }); + + this.slots.set(3, new Slot(slotFour.container, slotFour.index, slotFour.x, slotFour.y) { + @Override + public boolean mayPlace(@NotNull ItemStack stack) { + return true; + } + + @Override + public boolean mayPickup(net.minecraft.world.entity.player.@NotNull Player playerEntity) { + return true; + } + + @Override + public void onTake(net.minecraft.world.entity.player.@NotNull Player player, @NotNull ItemStack stack) { + slotFour.onTake(player, stack); + } + }); + } + + @Contract(pure = true, value = "_ -> true") + @Override + public boolean stillValid(@Nullable net.minecraft.world.entity.player.Player nmsPlayer) { + return true; + } + + @Override + public void slotsChanged(Container container) {} + + @Override + public void removed(net.minecraft.world.entity.player.Player nmsPlayer) {} + + @Override + public void createResult() {} + + @Override + protected void onTake(net.minecraft.world.entity.player.Player player, ItemStack stack) {} + + @Override + protected boolean mayPickup(net.minecraft.world.entity.player.Player player, boolean present) { + return true; + } + + public int getContainerId() { + return this.containerId; + } + } +} diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/StonecutterInventoryImpl.java b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/StonecutterInventoryImpl.java new file mode 100644 index 00000000..52e648d9 --- /dev/null +++ b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/StonecutterInventoryImpl.java @@ -0,0 +1,222 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_2; + +import com.github.stefvanschie.inventoryframework.abstraction.StonecutterInventory; +import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.TextHolderUtil; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerPlayerConnection; +import net.minecraft.world.Container; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.StonecutterMenu; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftInventoryStonecutter; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_21_R2.inventory.view.CraftStonecutterView; +import org.bukkit.entity.Player; +import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.reflect.Field; + +/** + * Internal stonecutter inventory for 1.21.2 + * + * @since 0.10.18 + */ +public class StonecutterInventoryImpl extends StonecutterInventory { + + public StonecutterInventoryImpl(@NotNull InventoryHolder inventoryHolder) { + super(inventoryHolder); + } + + @Override + public void openInventory(@NotNull Player player, @NotNull TextHolder title, + @Nullable org.bukkit.inventory.ItemStack[] items) { + int itemAmount = items.length; + + if (itemAmount != 2) { + throw new IllegalArgumentException( + "The amount of items for a stonecutter should be 2, but is '" + itemAmount + "'" + ); + } + + ServerPlayer serverPlayer = getServerPlayer(player); + Component message = TextHolderUtil.toComponent(title); + ContainerStonecutterImpl containerEnchantmentTable = new ContainerStonecutterImpl(serverPlayer, items, message); + + serverPlayer.containerMenu = containerEnchantmentTable; + + int id = containerEnchantmentTable.containerId; + ClientboundOpenScreenPacket packet = new ClientboundOpenScreenPacket(id, MenuType.STONECUTTER, message); + + serverPlayer.connection.send(packet); + + sendItems(player, items); + } + + @Override + public void sendItems(@NotNull Player player, @Nullable org.bukkit.inventory.ItemStack[] items) { + NonNullList nmsItems = NonNullList.of( + ItemStack.EMPTY, + CraftItemStack.asNMSCopy(items[0]), + CraftItemStack.asNMSCopy(items[1]) + ); + + ServerPlayer serverPlayer = getServerPlayer(player); + int containerId = getContainerId(serverPlayer); + int state = serverPlayer.containerMenu.incrementStateId(); + ItemStack cursor = CraftItemStack.asNMSCopy(player.getItemOnCursor()); + ServerPlayerConnection playerConnection = getPlayerConnection(serverPlayer); + + playerConnection.send(new ClientboundContainerSetContentPacket(containerId, state, nmsItems, cursor)); + } + + @Override + public void clearCursor(@NotNull Player player) { + ServerPlayer serverPlayer = getServerPlayer(player); + int state = serverPlayer.containerMenu.incrementStateId(); + + getPlayerConnection(serverPlayer).send(new ClientboundContainerSetSlotPacket(-1, state, -1, ItemStack.EMPTY)); + } + + /** + * Gets the container id for the inventory view the player currently has open + * + * @param nmsPlayer the player to get the container id for + * @return the container id + * @since 0.10.18 + */ + @Contract(pure = true) + private int getContainerId(@NotNull net.minecraft.world.entity.player.Player nmsPlayer) { + return nmsPlayer.containerMenu.containerId; + } + + /** + * Gets the player connection for the specified player + * + * @param serverPlayer the player to get the player connection from + * @return the player connection + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayerConnection getPlayerConnection(@NotNull ServerPlayer serverPlayer) { + return serverPlayer.connection; + } + + /** + * Gets the server player associated to this player + * + * @param player the player to get the server player from + * @return the server player + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private ServerPlayer getServerPlayer(@NotNull Player player) { + return ((CraftPlayer) player).getHandle(); + } + + /** + * A custom container enchanting table + * + * @since 0.10.18 + */ + private class ContainerStonecutterImpl extends StonecutterMenu { + + /** + * The player for this enchanting table container + */ + @NotNull + private final Player player; + + /** + * The internal bukkit entity for this container enchanting table + */ + @Nullable + private CraftStonecutterView bukkitEntity; + + /** + * Field for accessing the result inventory field + */ + @NotNull + private final Field resultContainerField; + + public ContainerStonecutterImpl(@NotNull ServerPlayer entityPlayer, + @Nullable org.bukkit.inventory.ItemStack[] items, @NotNull Component title) { + super(entityPlayer.nextContainerCounter(), entityPlayer.getInventory()); + + this.player = entityPlayer.getBukkitEntity(); + + setTitle(title); + + try { + //noinspection JavaReflectionMemberAccess + this.resultContainerField = StonecutterMenu.class.getDeclaredField("C"); //resultContainer + this.resultContainerField.setAccessible(true); + } catch (NoSuchFieldException exception) { + throw new RuntimeException(exception); + } + + container.setItem(0, CraftItemStack.asNMSCopy(items[0])); + getResultInventory().setItem(0, CraftItemStack.asNMSCopy(items[1])); + } + + @NotNull + @Override + public CraftStonecutterView getBukkitView() { + if (bukkitEntity == null) { + org.bukkit.inventory.StonecutterInventory inventory = new CraftInventoryStonecutter( + this.container, getResultInventory() + ) { + @NotNull + @Contract(pure = true) + @Override + public InventoryHolder getHolder() { + return inventoryHolder; + } + }; + + this.bukkitEntity = new CraftStonecutterView(player, inventory, this); + } + + return bukkitEntity; + } + + @Contract(pure = true, value = "_ -> true") + @Override + public boolean stillValid(@Nullable net.minecraft.world.entity.player.Player nmsPlayer) { + return true; + } + + @Override + public void slotsChanged(Container container) {} + + @Override + public void removed(net.minecraft.world.entity.player.Player nmsPlayer) {} + + /** + * Gets the result inventory + * + * @return the result inventory + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + public Container getResultInventory() { + try { + return (Container) resultContainerField.get(this); + } catch (IllegalAccessException exception) { + throw new RuntimeException(exception); + } + } + } +} diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/util/CustomInventoryUtil.java b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/util/CustomInventoryUtil.java new file mode 100644 index 00000000..145921a6 --- /dev/null +++ b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/util/CustomInventoryUtil.java @@ -0,0 +1,41 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_2.util; + +import net.minecraft.core.NonNullList; +import net.minecraft.world.item.ItemStack; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A utility class for custom inventories + * + * @since 0.10.18 + */ +public final class CustomInventoryUtil { + + /** + * A private constructor to prevent construction. + */ + private CustomInventoryUtil() {} + + /** + * Converts an array of Bukkit items into a non-null list of NMS items. The returned list is modifiable. If no items + * were specified, this returns an empty list. + * + * @param items the items to convert + * @return a list of converted items + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + public static NonNullList convertToNMSItems(@Nullable org.bukkit.inventory.ItemStack @NotNull [] items) { + NonNullList nmsItems = NonNullList.create(); + + for (org.bukkit.inventory.ItemStack item : items) { + nmsItems.add(CraftItemStack.asNMSCopy(item)); + } + + return nmsItems; + } +} diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/util/TextHolderUtil.java b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/util/TextHolderUtil.java new file mode 100644 index 00000000..d715014b --- /dev/null +++ b/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/util/TextHolderUtil.java @@ -0,0 +1,67 @@ +package com.github.stefvanschie.inventoryframework.nms.v1_21_2.util; + +import com.github.stefvanschie.inventoryframework.adventuresupport.ComponentHolder; +import com.github.stefvanschie.inventoryframework.adventuresupport.StringHolder; +import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; +import net.minecraft.core.HolderLookup; +import net.minecraft.network.chat.Component; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; +import java.util.stream.Stream; + +/** + * A utility class for adding {@link TextHolder} support. + * + * @since 0.10.18 + */ +public final class TextHolderUtil { + + private TextHolderUtil() { + //private constructor to prevent construction + } + + /** + * Converts the specified value to a vanilla component. + * + * @param holder the value to convert + * @return the value as a vanilla component + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + public static Component toComponent(@NotNull TextHolder holder) { + if (holder instanceof StringHolder) { + return toComponent((StringHolder) holder); + } else { + return toComponent((ComponentHolder) holder); + } + } + + /** + * Converts the specified legacy string holder to a vanilla component. + * + * @param holder the value to convert + * @return the value as a vanilla component + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private static Component toComponent(@NotNull StringHolder holder) { + return Component.literal(holder.asLegacyString()); + } + + /** + * Converts the specified Adventure component holder to a vanilla component. + * + * @param holder the value to convert + * @return the value as a vanilla component + * @since 0.10.18 + */ + @NotNull + @Contract(pure = true) + private static Component toComponent(@NotNull ComponentHolder holder) { + return Objects.requireNonNull(Component.Serializer.fromJson(holder.asJson(), HolderLookup.Provider.create(Stream.empty()))); + } +} diff --git a/pom.xml b/pom.xml index f34a6e70..b62668d4 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,7 @@ IF nms/abstraction + nms/1_21_2 nms/1_21_1 nms/1_21_0 nms/1_20_6 From 60b19dc29ee4bc0fc0b812590a4675ba03270499 Mon Sep 17 00:00:00 2001 From: stefvanschie Date: Thu, 31 Oct 2024 20:24:54 +0100 Subject: [PATCH 35/40] Add 1.21.3 support --- IF/pom.xml | 2 +- .../util/version/Version.java | 11 ++++--- .../util/version/VersionMatcher.java | 32 +++++++++---------- nms/{1_21_2 => 1_21_2-3}/pom.xml | 12 +++---- .../nms/v1_21_2_3}/AnvilInventoryImpl.java | 6 ++-- .../nms/v1_21_2_3}/BeaconInventoryImpl.java | 2 +- .../CartographyTableInventoryImpl.java | 6 ++-- .../EnchantingTableInventoryImpl.java | 4 +-- .../v1_21_2_3}/GrindstoneInventoryImpl.java | 6 ++-- .../nms/v1_21_2_3}/MerchantInventoryImpl.java | 2 +- .../SmithingTableInventoryImpl.java | 6 ++-- .../v1_21_2_3}/StonecutterInventoryImpl.java | 4 +-- .../v1_21_2_3}/util/CustomInventoryUtil.java | 2 +- .../nms/v1_21_2_3}/util/TextHolderUtil.java | 2 +- pom.xml | 2 +- 15 files changed, 50 insertions(+), 49 deletions(-) rename nms/{1_21_2 => 1_21_2-3}/pom.xml (89%) rename nms/{1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2 => 1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3}/AnvilInventoryImpl.java (97%) rename nms/{1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2 => 1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3}/BeaconInventoryImpl.java (99%) rename nms/{1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2 => 1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3}/CartographyTableInventoryImpl.java (96%) rename nms/{1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2 => 1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3}/EnchantingTableInventoryImpl.java (98%) rename nms/{1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2 => 1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3}/GrindstoneInventoryImpl.java (96%) rename nms/{1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2 => 1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3}/MerchantInventoryImpl.java (98%) rename nms/{1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2 => 1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3}/SmithingTableInventoryImpl.java (98%) rename nms/{1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2 => 1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3}/StonecutterInventoryImpl.java (98%) rename nms/{1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2 => 1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3}/util/CustomInventoryUtil.java (94%) rename nms/{1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2 => 1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3}/util/TextHolderUtil.java (96%) diff --git a/IF/pom.xml b/IF/pom.xml index b88c7040..5b9d4e6c 100644 --- a/IF/pom.xml +++ b/IF/pom.xml @@ -181,7 +181,7 @@ com.github.stefvanschie.inventoryframework - 1_21_2 + 1_21_2-3 ${project.version} compile diff --git a/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/Version.java b/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/Version.java index fab2b06e..93ddce44 100644 --- a/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/Version.java +++ b/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/Version.java @@ -178,11 +178,11 @@ public enum Version { V1_21_1, /** - * Version 1.21.2 + * Version 1.21.2 - 1.21.3 * * @since 0.10.18 */ - V1_21_2; + V1_21_2_3; /** * A collection of versions on which modern smithing tables are available. @@ -190,7 +190,7 @@ public enum Version { private static final Collection MODERN_SMITHING_TABLE_VERSIONS = EnumSet.of( V1_19_4, V1_20_0, V1_20_1, V1_20_2, V1_20_3_4, V1_20_5, V1_20_6, - V1_21_0, V1_21_1, V1_21_2 + V1_21_0, V1_21_1, V1_21_2_3 ); /** @@ -211,7 +211,7 @@ public enum Version { */ @NotNull private static final Collection<@NotNull Version> INTERFACE_INVENTORY_VIEW = EnumSet.of( - V1_21_0, V1_21_1, V1_21_2 + V1_21_0, V1_21_1, V1_21_2_3 ); /** @@ -315,7 +315,8 @@ public static Version getVersion() { case "1.21.1": return V1_21_1; case "1.21.2": - return V1_21_2; + case "1.21.3": + return V1_21_2_3; default: throw new UnsupportedVersionException("The server version provided is not supported"); } diff --git a/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/VersionMatcher.java b/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/VersionMatcher.java index 63f7c8b7..5ef83680 100644 --- a/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/VersionMatcher.java +++ b/IF/src/main/java/com/github/stefvanschie/inventoryframework/util/version/VersionMatcher.java @@ -321,8 +321,8 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.AnvilInventoryImpl.class); ANVIL_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.AnvilInventoryImpl.class); - ANVIL_INVENTORIES.put(Version.V1_21_2, - com.github.stefvanschie.inventoryframework.nms.v1_21_2.AnvilInventoryImpl.class); + ANVIL_INVENTORIES.put(Version.V1_21_2_3, + com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.AnvilInventoryImpl.class); BEACON_INVENTORIES = new EnumMap<>(Version.class); BEACON_INVENTORIES.put(Version.V1_14, @@ -371,8 +371,8 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.BeaconInventoryImpl.class); BEACON_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.BeaconInventoryImpl.class); - BEACON_INVENTORIES.put(Version.V1_21_2, - com.github.stefvanschie.inventoryframework.nms.v1_21_2.BeaconInventoryImpl.class); + BEACON_INVENTORIES.put(Version.V1_21_2_3, + com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.BeaconInventoryImpl.class); CARTOGRAPHY_TABLE_INVENTORIES = new EnumMap<>(Version.class); CARTOGRAPHY_TABLE_INVENTORIES.put(Version.V1_14, @@ -421,8 +421,8 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.CartographyTableInventoryImpl.class); CARTOGRAPHY_TABLE_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.CartographyTableInventoryImpl.class); - CARTOGRAPHY_TABLE_INVENTORIES.put(Version.V1_21_2, - com.github.stefvanschie.inventoryframework.nms.v1_21_2.CartographyTableInventoryImpl.class); + CARTOGRAPHY_TABLE_INVENTORIES.put(Version.V1_21_2_3, + com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.CartographyTableInventoryImpl.class); ENCHANTING_TABLE_INVENTORIES = new EnumMap<>(Version.class); ENCHANTING_TABLE_INVENTORIES.put(Version.V1_14, @@ -471,8 +471,8 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.EnchantingTableInventoryImpl.class); ENCHANTING_TABLE_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.EnchantingTableInventoryImpl.class); - ENCHANTING_TABLE_INVENTORIES.put(Version.V1_21_2, - com.github.stefvanschie.inventoryframework.nms.v1_21_2.EnchantingTableInventoryImpl.class); + ENCHANTING_TABLE_INVENTORIES.put(Version.V1_21_2_3, + com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.EnchantingTableInventoryImpl.class); GRINDSTONE_INVENTORIES = new EnumMap<>(Version.class); GRINDSTONE_INVENTORIES.put(Version.V1_14, @@ -521,8 +521,8 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.GrindstoneInventoryImpl.class); GRINDSTONE_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.GrindstoneInventoryImpl.class); - GRINDSTONE_INVENTORIES.put(Version.V1_21_2, - com.github.stefvanschie.inventoryframework.nms.v1_21_2.GrindstoneInventoryImpl.class); + GRINDSTONE_INVENTORIES.put(Version.V1_21_2_3, + com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.GrindstoneInventoryImpl.class); MERCHANT_INVENTORIES = new EnumMap<>(Version.class); MERCHANT_INVENTORIES.put(Version.V1_14, @@ -571,8 +571,8 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.MerchantInventoryImpl.class); MERCHANT_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.MerchantInventoryImpl.class); - MERCHANT_INVENTORIES.put(Version.V1_21_2, - com.github.stefvanschie.inventoryframework.nms.v1_21_2.MerchantInventoryImpl.class); + MERCHANT_INVENTORIES.put(Version.V1_21_2_3, + com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.MerchantInventoryImpl.class); SMITHING_TABLE_INVENTORIES = new EnumMap<>(Version.class); SMITHING_TABLE_INVENTORIES.put(Version.V1_19_4, @@ -593,8 +593,8 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.SmithingTableInventoryImpl.class); SMITHING_TABLE_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.SmithingTableInventoryImpl.class); - SMITHING_TABLE_INVENTORIES.put(Version.V1_21_2, - com.github.stefvanschie.inventoryframework.nms.v1_21_2.SmithingTableInventoryImpl.class); + SMITHING_TABLE_INVENTORIES.put(Version.V1_21_2_3, + com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.SmithingTableInventoryImpl.class); LEGACY_SMITHING_TABLE_INVENTORIES = new EnumMap<>(Version.class); LEGACY_SMITHING_TABLE_INVENTORIES.put(Version.V1_16_1, @@ -671,7 +671,7 @@ public static StonecutterInventory newStonecutterInventory(@NotNull Version vers com.github.stefvanschie.inventoryframework.nms.v1_21_0.StonecutterInventoryImpl.class); STONECUTTER_INVENTORIES.put(Version.V1_21_1, com.github.stefvanschie.inventoryframework.nms.v1_21_1.StonecutterInventoryImpl.class); - STONECUTTER_INVENTORIES.put(Version.V1_21_2, - com.github.stefvanschie.inventoryframework.nms.v1_21_2.StonecutterInventoryImpl.class); + STONECUTTER_INVENTORIES.put(Version.V1_21_2_3, + com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.StonecutterInventoryImpl.class); } } diff --git a/nms/1_21_2/pom.xml b/nms/1_21_2-3/pom.xml similarity index 89% rename from nms/1_21_2/pom.xml rename to nms/1_21_2-3/pom.xml index 943aabb8..f02078b1 100644 --- a/nms/1_21_2/pom.xml +++ b/nms/1_21_2-3/pom.xml @@ -10,7 +10,7 @@ ../../pom.xml - 1_21_2 + 1_21_2-3 true @@ -26,7 +26,7 @@ org.spigotmc spigot - 1.21.2-R0.1-SNAPSHOT + 1.21.3-R0.1-SNAPSHOT remapped-mojang provided @@ -46,9 +46,9 @@ remap-obf - org.spigotmc:minecraft-server:1.21.2-R0.1-SNAPSHOT:txt:maps-mojang + org.spigotmc:minecraft-server:1.21.3-R0.1-SNAPSHOT:txt:maps-mojang true - org.spigotmc:spigot:1.21.2-R0.1-SNAPSHOT:jar:remapped-mojang + org.spigotmc:spigot:1.21.3-R0.1-SNAPSHOT:jar:remapped-mojang true remapped-obf @@ -61,8 +61,8 @@ remap-spigot ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:1.21.2-R0.1-SNAPSHOT:csrg:maps-spigot - org.spigotmc:spigot:1.21.2-R0.1-SNAPSHOT:jar:remapped-obf + org.spigotmc:minecraft-server:1.21.3-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.21.3-R0.1-SNAPSHOT:jar:remapped-obf diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/AnvilInventoryImpl.java b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/AnvilInventoryImpl.java similarity index 97% rename from nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/AnvilInventoryImpl.java rename to nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/AnvilInventoryImpl.java index ad7e2de9..0b3aa092 100644 --- a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/AnvilInventoryImpl.java +++ b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/AnvilInventoryImpl.java @@ -1,9 +1,9 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21_2; +package com.github.stefvanschie.inventoryframework.nms.v1_21_2_3; import com.github.stefvanschie.inventoryframework.abstraction.AnvilInventory; import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; -import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.CustomInventoryUtil; -import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.TextHolderUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.util.TextHolderUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/BeaconInventoryImpl.java b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/BeaconInventoryImpl.java similarity index 99% rename from nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/BeaconInventoryImpl.java rename to nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/BeaconInventoryImpl.java index c8ef5444..34faf64c 100644 --- a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/BeaconInventoryImpl.java +++ b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/BeaconInventoryImpl.java @@ -1,4 +1,4 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21_2; +package com.github.stefvanschie.inventoryframework.nms.v1_21_2_3; import com.github.stefvanschie.inventoryframework.abstraction.BeaconInventory; import net.minecraft.core.NonNullList; diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/CartographyTableInventoryImpl.java b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/CartographyTableInventoryImpl.java similarity index 96% rename from nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/CartographyTableInventoryImpl.java rename to nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/CartographyTableInventoryImpl.java index 905f3ce8..ef2b9a2b 100644 --- a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/CartographyTableInventoryImpl.java +++ b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/CartographyTableInventoryImpl.java @@ -1,9 +1,9 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21_2; +package com.github.stefvanschie.inventoryframework.nms.v1_21_2_3; import com.github.stefvanschie.inventoryframework.abstraction.CartographyTableInventory; import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; -import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.CustomInventoryUtil; -import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.TextHolderUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.util.TextHolderUtil; import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/EnchantingTableInventoryImpl.java b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/EnchantingTableInventoryImpl.java similarity index 98% rename from nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/EnchantingTableInventoryImpl.java rename to nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/EnchantingTableInventoryImpl.java index 8b9fab94..c4cec265 100644 --- a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/EnchantingTableInventoryImpl.java +++ b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/EnchantingTableInventoryImpl.java @@ -1,8 +1,8 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21_2; +package com.github.stefvanschie.inventoryframework.nms.v1_21_2_3; import com.github.stefvanschie.inventoryframework.abstraction.EnchantingTableInventory; import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; -import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.TextHolderUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.util.TextHolderUtil; import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/GrindstoneInventoryImpl.java b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/GrindstoneInventoryImpl.java similarity index 96% rename from nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/GrindstoneInventoryImpl.java rename to nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/GrindstoneInventoryImpl.java index da238f42..c9796f49 100644 --- a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/GrindstoneInventoryImpl.java +++ b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/GrindstoneInventoryImpl.java @@ -1,9 +1,9 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21_2; +package com.github.stefvanschie.inventoryframework.nms.v1_21_2_3; import com.github.stefvanschie.inventoryframework.abstraction.GrindstoneInventory; import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; -import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.CustomInventoryUtil; -import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.TextHolderUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.util.TextHolderUtil; import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/MerchantInventoryImpl.java b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/MerchantInventoryImpl.java similarity index 98% rename from nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/MerchantInventoryImpl.java rename to nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/MerchantInventoryImpl.java index 4ce1393b..7f64c878 100644 --- a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/MerchantInventoryImpl.java +++ b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/MerchantInventoryImpl.java @@ -1,4 +1,4 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21_2; +package com.github.stefvanschie.inventoryframework.nms.v1_21_2_3; import com.github.stefvanschie.inventoryframework.abstraction.MerchantInventory; import net.minecraft.core.component.DataComponentPredicate; diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/SmithingTableInventoryImpl.java b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/SmithingTableInventoryImpl.java similarity index 98% rename from nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/SmithingTableInventoryImpl.java rename to nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/SmithingTableInventoryImpl.java index ddb5aeff..03457ad7 100644 --- a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/SmithingTableInventoryImpl.java +++ b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/SmithingTableInventoryImpl.java @@ -1,9 +1,9 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21_2; +package com.github.stefvanschie.inventoryframework.nms.v1_21_2_3; import com.github.stefvanschie.inventoryframework.abstraction.SmithingTableInventory; import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; -import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.CustomInventoryUtil; -import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.TextHolderUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.util.CustomInventoryUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.util.TextHolderUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/StonecutterInventoryImpl.java b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/StonecutterInventoryImpl.java similarity index 98% rename from nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/StonecutterInventoryImpl.java rename to nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/StonecutterInventoryImpl.java index 52e648d9..18d57027 100644 --- a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/StonecutterInventoryImpl.java +++ b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/StonecutterInventoryImpl.java @@ -1,8 +1,8 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21_2; +package com.github.stefvanschie.inventoryframework.nms.v1_21_2_3; import com.github.stefvanschie.inventoryframework.abstraction.StonecutterInventory; import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder; -import com.github.stefvanschie.inventoryframework.nms.v1_21_2.util.TextHolderUtil; +import com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.util.TextHolderUtil; import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/util/CustomInventoryUtil.java b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/util/CustomInventoryUtil.java similarity index 94% rename from nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/util/CustomInventoryUtil.java rename to nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/util/CustomInventoryUtil.java index 145921a6..eb2257b9 100644 --- a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/util/CustomInventoryUtil.java +++ b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/util/CustomInventoryUtil.java @@ -1,4 +1,4 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21_2.util; +package com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.util; import net.minecraft.core.NonNullList; import net.minecraft.world.item.ItemStack; diff --git a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/util/TextHolderUtil.java b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/util/TextHolderUtil.java similarity index 96% rename from nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/util/TextHolderUtil.java rename to nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/util/TextHolderUtil.java index d715014b..4f807583 100644 --- a/nms/1_21_2/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2/util/TextHolderUtil.java +++ b/nms/1_21_2-3/src/main/java/com/github/stefvanschie/inventoryframework/nms/v1_21_2_3/util/TextHolderUtil.java @@ -1,4 +1,4 @@ -package com.github.stefvanschie.inventoryframework.nms.v1_21_2.util; +package com.github.stefvanschie.inventoryframework.nms.v1_21_2_3.util; import com.github.stefvanschie.inventoryframework.adventuresupport.ComponentHolder; import com.github.stefvanschie.inventoryframework.adventuresupport.StringHolder; diff --git a/pom.xml b/pom.xml index b62668d4..668df9c2 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ IF nms/abstraction - nms/1_21_2 + nms/1_21_2-3 nms/1_21_1 nms/1_21_0 nms/1_20_6 From 0ea0def776af87b55eea9d2b561bb773834a431c Mon Sep 17 00:00:00 2001 From: stefvanschie Date: Thu, 31 Oct 2024 20:53:04 +0100 Subject: [PATCH 36/40] Fix CI/CD & dependabot --- .github/dependabot.yml | 4 ++++ .github/workflows/auto-deploy.yml | 3 ++- .github/workflows/maven.yml | 3 ++- README.md | 21 ++++++++++++++++++++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fb2210cf..2472e19a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -104,6 +104,10 @@ updates: directory: "/nms/1_21_1" schedule: interval: "daily" + - package-ecosystem: "maven" + directory: "/nms/1_21_2-3" + schedule: + interval: "daily" - package-ecosystem: "maven" directory: "/nms/abstraction" schedule: diff --git a/.github/workflows/auto-deploy.yml b/.github/workflows/auto-deploy.yml index 9c671e5b..5db9d040 100644 --- a/.github/workflows/auto-deploy.yml +++ b/.github/workflows/auto-deploy.yml @@ -76,7 +76,7 @@ jobs: mvn paper-nms:init -pl nms/1_20_1 mvn paper-nms:init -pl nms/1_20_2 mvn paper-nms:init -pl nms/1_20_3-4 - - name: 'Run BuildTools 1.20.5-1.20.6, 1.21.1' + - name: 'Run BuildTools 1.20.5-1.20.6, 1.21' if: steps.cache-paperclip-jars.outputs.cache-hit != 'true' run: | mkdir -p build @@ -142,6 +142,7 @@ jobs: cd .. java -jar BuildTools.jar --remapped --disable-java-check --dont-update + java -jar BuildTools.jar --rev 1.21.3 --remapped --disable-java-check cd ../ - name: Setup GPG keys diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 1608ec05..9113fa10 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -82,7 +82,7 @@ jobs: mvn paper-nms:init -pl nms/1_20_1 mvn paper-nms:init -pl nms/1_20_2 mvn paper-nms:init -pl nms/1_20_3-4 - - name: 'Run BuildTools 1.20.5-1.20.6, 1.21.1' + - name: 'Run BuildTools 1.20.5-1.20.6, 1.21' if: steps.cache-paperclip-jars.outputs.cache-hit != 'true' run: | mkdir -p build @@ -148,6 +148,7 @@ jobs: cd .. java -jar BuildTools.jar --remapped --disable-java-check --dont-update + java -jar BuildTools.jar --rev 1.21.3 --remapped --disable-java-check cd ../ - name: Build with Maven diff --git a/README.md b/README.md index 4d04840d..7fc917bc 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ mvn paper-nms:init -pl nms/1_20_3-4 ``` ### Installing Spigot via BuildTools -For versions 1.20.5-1.21.1, we use BuildTools. To install these versions, we run the following commands. +For versions 1.20.5-1.21.3, we use BuildTools. To install these versions, we run the following commands. ``` wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar -O BuildTools.jar @@ -187,6 +187,25 @@ cd .. java -jar BuildTools.jar --remapped --disable-java-check --dont-update java -jar BuildTools.jar --rev 1.21.1 --remapped --disable-java-check + +cd Bukkit +git checkout 8ec77750aa334e886ed2a0cee3320c62985b28e3 +cd .. + +cd CraftBukkit +git checkout d50f50585eab860db7889b3e736a62faf430f7a4 +cd .. + +cd Spigot +git checkout a084d85da8604d468f81091f56dc81166d912931 +cd .. + +cd BuildData +git checkout 0ea6fcc9bc8ad9e7c729f5031123bcc69ce2b033 +cd .. + +java -jar BuildTools.jar --remapped --disable-java-check --dont-update +java -jar BuildTools.jar --rev 1.21.3 --remapped --disable-java-check ``` Your environment is now set up correctly. To create a build, run the following inside the root folder of the project. From 07d811cf03709b89561acd1ce8d1f62b5d8e04c8 Mon Sep 17 00:00:00 2001 From: stefvanschie Date: Sat, 2 Nov 2024 21:11:58 +0100 Subject: [PATCH 37/40] Remove 1.21.2 from CI/CD --- .github/workflows/auto-deploy.yml | 18 ------------------ .github/workflows/maven.yml | 18 ------------------ README.md | 18 ------------------ 3 files changed, 54 deletions(-) diff --git a/.github/workflows/auto-deploy.yml b/.github/workflows/auto-deploy.yml index 5db9d040..0ec441f2 100644 --- a/.github/workflows/auto-deploy.yml +++ b/.github/workflows/auto-deploy.yml @@ -124,24 +124,6 @@ jobs: java -jar BuildTools.jar --remapped --disable-java-check --dont-update java -jar BuildTools.jar --rev 1.21.1 --remapped --disable-java-check - - cd Bukkit - git checkout 8ec77750aa334e886ed2a0cee3320c62985b28e3 - cd .. - - cd CraftBukkit - git checkout d50f50585eab860db7889b3e736a62faf430f7a4 - cd .. - - cd Spigot - git checkout a084d85da8604d468f81091f56dc81166d912931 - cd .. - - cd BuildData - git checkout 0ea6fcc9bc8ad9e7c729f5031123bcc69ce2b033 - cd .. - - java -jar BuildTools.jar --remapped --disable-java-check --dont-update java -jar BuildTools.jar --rev 1.21.3 --remapped --disable-java-check cd ../ diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9113fa10..ae799f8a 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -130,24 +130,6 @@ jobs: java -jar BuildTools.jar --remapped --disable-java-check --dont-update java -jar BuildTools.jar --rev 1.21.1 --remapped --disable-java-check - - cd Bukkit - git checkout 8ec77750aa334e886ed2a0cee3320c62985b28e3 - cd .. - - cd CraftBukkit - git checkout d50f50585eab860db7889b3e736a62faf430f7a4 - cd .. - - cd Spigot - git checkout a084d85da8604d468f81091f56dc81166d912931 - cd .. - - cd BuildData - git checkout 0ea6fcc9bc8ad9e7c729f5031123bcc69ce2b033 - cd .. - - java -jar BuildTools.jar --remapped --disable-java-check --dont-update java -jar BuildTools.jar --rev 1.21.3 --remapped --disable-java-check cd ../ diff --git a/README.md b/README.md index 7fc917bc..a73790f5 100644 --- a/README.md +++ b/README.md @@ -187,24 +187,6 @@ cd .. java -jar BuildTools.jar --remapped --disable-java-check --dont-update java -jar BuildTools.jar --rev 1.21.1 --remapped --disable-java-check - -cd Bukkit -git checkout 8ec77750aa334e886ed2a0cee3320c62985b28e3 -cd .. - -cd CraftBukkit -git checkout d50f50585eab860db7889b3e736a62faf430f7a4 -cd .. - -cd Spigot -git checkout a084d85da8604d468f81091f56dc81166d912931 -cd .. - -cd BuildData -git checkout 0ea6fcc9bc8ad9e7c729f5031123bcc69ce2b033 -cd .. - -java -jar BuildTools.jar --remapped --disable-java-check --dont-update java -jar BuildTools.jar --rev 1.21.3 --remapped --disable-java-check ``` From 0a1d721e1788dd8aac85de540a34ae6c7c0b0dc4 Mon Sep 17 00:00:00 2001 From: stefvanschie Date: Mon, 4 Nov 2024 21:14:24 +0100 Subject: [PATCH 38/40] V 0.10.18 --- IF/pom.xml | 2 +- README.md | 4 ++-- adventure-support/pom.xml | 2 +- inventory-view/iv-abstract-class/pom.xml | 2 +- inventory-view/iv-abstraction/pom.xml | 2 +- inventory-view/iv-interface/pom.xml | 2 +- nms/1_14/pom.xml | 2 +- nms/1_15/pom.xml | 2 +- nms/1_16_1/pom.xml | 2 +- nms/1_16_2-3/pom.xml | 2 +- nms/1_16_4-5/pom.xml | 2 +- nms/1_17_0/pom.xml | 2 +- nms/1_17_1/pom.xml | 2 +- nms/1_18_0/pom.xml | 2 +- nms/1_18_1/pom.xml | 2 +- nms/1_18_2/pom.xml | 2 +- nms/1_19_0/pom.xml | 2 +- nms/1_19_1/pom.xml | 2 +- nms/1_19_2/pom.xml | 2 +- nms/1_19_3/pom.xml | 2 +- nms/1_19_4/pom.xml | 2 +- nms/1_20_0/pom.xml | 2 +- nms/1_20_1/pom.xml | 2 +- nms/1_20_2/pom.xml | 2 +- nms/1_20_3-4/pom.xml | 2 +- nms/1_20_5/pom.xml | 2 +- nms/1_20_6/pom.xml | 2 +- nms/1_21_0/pom.xml | 2 +- nms/1_21_1/pom.xml | 2 +- nms/1_21_2-3/pom.xml | 2 +- nms/abstraction/pom.xml | 2 +- pom.xml | 2 +- 32 files changed, 33 insertions(+), 33 deletions(-) diff --git a/IF/pom.xml b/IF/pom.xml index 5b9d4e6c..f5ebf60b 100644 --- a/IF/pom.xml +++ b/IF/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../pom.xml 4.0.0 diff --git a/README.md b/README.md index a73790f5..66687244 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ To add this project as a dependency to your pom.xml, add the following to your p com.github.stefvanschie.inventoryframework IF - 0.10.17 + 0.10.18 ``` The project is in the Central Repository, so specifying a repository is not needed. @@ -50,7 +50,7 @@ Replace [YOUR PACKAGE] with the top-level package of your project. To add this project as a dependency for your Gradle project, make sure your `dependencies` section of your build.gradle looks like the following: ```Groovy dependencies { - implementation 'com.github.stefvanschie.inventoryframework:IF:0.10.17' + implementation 'com.github.stefvanschie.inventoryframework:IF:0.10.18' // ... } ``` diff --git a/adventure-support/pom.xml b/adventure-support/pom.xml index 2e95e746..3d4bb888 100644 --- a/adventure-support/pom.xml +++ b/adventure-support/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 4.0.0 diff --git a/inventory-view/iv-abstract-class/pom.xml b/inventory-view/iv-abstract-class/pom.xml index bf33ff28..ea1a52a8 100644 --- a/inventory-view/iv-abstract-class/pom.xml +++ b/inventory-view/iv-abstract-class/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml diff --git a/inventory-view/iv-abstraction/pom.xml b/inventory-view/iv-abstraction/pom.xml index 1588aad1..c03fa67b 100644 --- a/inventory-view/iv-abstraction/pom.xml +++ b/inventory-view/iv-abstraction/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml diff --git a/inventory-view/iv-interface/pom.xml b/inventory-view/iv-interface/pom.xml index 8e389285..cd6e8cf4 100644 --- a/inventory-view/iv-interface/pom.xml +++ b/inventory-view/iv-interface/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml diff --git a/nms/1_14/pom.xml b/nms/1_14/pom.xml index 79d81892..dad32016 100644 --- a/nms/1_14/pom.xml +++ b/nms/1_14/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/nms/1_15/pom.xml b/nms/1_15/pom.xml index faac5f27..c85530eb 100644 --- a/nms/1_15/pom.xml +++ b/nms/1_15/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/nms/1_16_1/pom.xml b/nms/1_16_1/pom.xml index 046d2491..6ad0fba2 100644 --- a/nms/1_16_1/pom.xml +++ b/nms/1_16_1/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/nms/1_16_2-3/pom.xml b/nms/1_16_2-3/pom.xml index 9fe11f67..147afb07 100644 --- a/nms/1_16_2-3/pom.xml +++ b/nms/1_16_2-3/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/nms/1_16_4-5/pom.xml b/nms/1_16_4-5/pom.xml index a86dd079..8f5722fb 100644 --- a/nms/1_16_4-5/pom.xml +++ b/nms/1_16_4-5/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/nms/1_17_0/pom.xml b/nms/1_17_0/pom.xml index 3637330f..9ed5e157 100644 --- a/nms/1_17_0/pom.xml +++ b/nms/1_17_0/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/nms/1_17_1/pom.xml b/nms/1_17_1/pom.xml index 79444e41..76b1958b 100644 --- a/nms/1_17_1/pom.xml +++ b/nms/1_17_1/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/nms/1_18_0/pom.xml b/nms/1_18_0/pom.xml index 2f5b42f7..26911cff 100644 --- a/nms/1_18_0/pom.xml +++ b/nms/1_18_0/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/nms/1_18_1/pom.xml b/nms/1_18_1/pom.xml index 47ff26df..cfa85309 100644 --- a/nms/1_18_1/pom.xml +++ b/nms/1_18_1/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/nms/1_18_2/pom.xml b/nms/1_18_2/pom.xml index 4a50cdf9..09e12156 100644 --- a/nms/1_18_2/pom.xml +++ b/nms/1_18_2/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/nms/1_19_0/pom.xml b/nms/1_19_0/pom.xml index f998d8ac..db868d97 100644 --- a/nms/1_19_0/pom.xml +++ b/nms/1_19_0/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/nms/1_19_1/pom.xml b/nms/1_19_1/pom.xml index 9624357a..2510e437 100644 --- a/nms/1_19_1/pom.xml +++ b/nms/1_19_1/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/nms/1_19_2/pom.xml b/nms/1_19_2/pom.xml index 40998988..a9d1888f 100644 --- a/nms/1_19_2/pom.xml +++ b/nms/1_19_2/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/nms/1_19_3/pom.xml b/nms/1_19_3/pom.xml index 54fc8e0c..1f792479 100644 --- a/nms/1_19_3/pom.xml +++ b/nms/1_19_3/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/nms/1_19_4/pom.xml b/nms/1_19_4/pom.xml index bc775d6e..9d84bb3b 100644 --- a/nms/1_19_4/pom.xml +++ b/nms/1_19_4/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/nms/1_20_0/pom.xml b/nms/1_20_0/pom.xml index 86cc53ff..4197a5b5 100644 --- a/nms/1_20_0/pom.xml +++ b/nms/1_20_0/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml diff --git a/nms/1_20_1/pom.xml b/nms/1_20_1/pom.xml index 8ccbc5ad..d6231fee 100644 --- a/nms/1_20_1/pom.xml +++ b/nms/1_20_1/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml diff --git a/nms/1_20_2/pom.xml b/nms/1_20_2/pom.xml index 2edecfe6..7e531ea4 100644 --- a/nms/1_20_2/pom.xml +++ b/nms/1_20_2/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml diff --git a/nms/1_20_3-4/pom.xml b/nms/1_20_3-4/pom.xml index 81e41633..6296cc76 100644 --- a/nms/1_20_3-4/pom.xml +++ b/nms/1_20_3-4/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml diff --git a/nms/1_20_5/pom.xml b/nms/1_20_5/pom.xml index 5bc065cb..ed3a0704 100644 --- a/nms/1_20_5/pom.xml +++ b/nms/1_20_5/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml diff --git a/nms/1_20_6/pom.xml b/nms/1_20_6/pom.xml index 4ff77993..0a522e95 100644 --- a/nms/1_20_6/pom.xml +++ b/nms/1_20_6/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml diff --git a/nms/1_21_0/pom.xml b/nms/1_21_0/pom.xml index 1de4e00a..662ae335 100644 --- a/nms/1_21_0/pom.xml +++ b/nms/1_21_0/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml diff --git a/nms/1_21_1/pom.xml b/nms/1_21_1/pom.xml index fdb0750d..a70e9df9 100644 --- a/nms/1_21_1/pom.xml +++ b/nms/1_21_1/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml diff --git a/nms/1_21_2-3/pom.xml b/nms/1_21_2-3/pom.xml index f02078b1..a042895c 100644 --- a/nms/1_21_2-3/pom.xml +++ b/nms/1_21_2-3/pom.xml @@ -6,7 +6,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml diff --git a/nms/abstraction/pom.xml b/nms/abstraction/pom.xml index 96032f6a..3d194bfe 100644 --- a/nms/abstraction/pom.xml +++ b/nms/abstraction/pom.xml @@ -5,7 +5,7 @@ IF-parent com.github.stefvanschie.inventoryframework - 0.10.18-SNAPSHOT + 0.10.18 ../../pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index 668df9c2..cce22aaf 100644 --- a/pom.xml +++ b/pom.xml @@ -47,7 +47,7 @@ com.github.stefvanschie.inventoryframework IF-parent - 0.10.18-SNAPSHOT + 0.10.18 pom IF From a2b7a07b3c13a6862c695621f1a17b3a8e9146bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 20:32:08 +0000 Subject: [PATCH 39/40] Bump org.apache.maven.plugins:maven-surefire-plugin in /nms/1_14 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index cce22aaf..7050fa7b 100644 --- a/pom.xml +++ b/pom.xml @@ -122,12 +122,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.0 + 3.5.2 org.apache.maven.surefire surefire-junit-platform - 3.5.0 + 3.5.2 org.junit.jupiter From b4091d3b2497f877f53ba39eefa740822171997b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 19:21:30 +0000 Subject: [PATCH 40/40] Bump org.apache.maven.surefire:surefire-junit-platform in /IF Bumps org.apache.maven.surefire:surefire-junit-platform from 3.2.5 to 3.5.0. --- updated-dependencies: - dependency-name: org.apache.maven.surefire:surefire-junit-platform dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- IF/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IF/pom.xml b/IF/pom.xml index 853eb2ce..e14f5591 100644 --- a/IF/pom.xml +++ b/IF/pom.xml @@ -284,7 +284,7 @@ org.apache.maven.surefire surefire-junit-platform - 3.5.0 + 3.5.2