Skip to content

Commit 08ad880

Browse files
committed
Add support for CraftBukkit 1.21.5 to InvSee++_Give.
1 parent ee9d3b6 commit 08ad880

File tree

8 files changed

+209
-2
lines changed

8 files changed

+209
-2
lines changed

InvSee++_Common/src/main/java/com/janboerman/invsee/spigot/internal/version/ServerSoftware.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ public static ServerSoftware detect(final Server server) {
133133
case CraftbukkitMappingsVersion._1_21_5: return CRAFTBUKKIT_1_21_5;
134134
}
135135
}
136-
137136
case "net.glowstone.GlowServer":
138137
final String glowstoneGameVersion = GlowstoneGameVersion.getGameVersion();
139138
switch (glowstoneGameVersion) {
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<parent>
3+
<relativePath>../../pom.xml</relativePath>
4+
<groupId>com.janboerman.invsee</groupId>
5+
<artifactId>invsee-plus-plus</artifactId>
6+
<version>0.29.20-SNAPSHOT</version>
7+
</parent>
8+
<modelVersion>4.0.0</modelVersion>
9+
10+
<artifactId>give_impl_1_21_5_r4</artifactId>
11+
<name>InvSee++ Give implementation for CraftBukkit 1.21.5</name>
12+
13+
<properties>
14+
<bukkit.version>1.21.5-R0.1-SNAPSHOT</bukkit.version>
15+
</properties>
16+
17+
<build>
18+
<plugins>
19+
<plugin>
20+
<groupId>org.apache.maven.plugins</groupId>
21+
<artifactId>maven-compiler-plugin</artifactId>
22+
<version>${maven-compiler-plugin.version}</version>
23+
<configuration>
24+
<release>21</release>
25+
</configuration>
26+
</plugin>
27+
28+
<plugin>
29+
<groupId>net.md-5</groupId>
30+
<artifactId>specialsource-maven-plugin</artifactId>
31+
<version>${specialsource-maven-plugin.version}</version>
32+
<executions>
33+
<execution>
34+
<phase>package</phase>
35+
<goals>
36+
<goal>remap</goal>
37+
</goals>
38+
<id>remap-obf</id>
39+
<configuration>
40+
<srgIn>org.spigotmc:minecraft-server:${bukkit.version}:txt:maps-mojang</srgIn>
41+
<reverse>true</reverse>
42+
<remappedDependencies>org.bukkit:craftbukkit:${bukkit.version}:jar:remapped-mojang</remappedDependencies>
43+
<remappedArtifactAttached>true</remappedArtifactAttached>
44+
<remappedClassifierName>remapped-obf</remappedClassifierName>
45+
</configuration>
46+
</execution>
47+
<execution>
48+
<phase>package</phase>
49+
<goals>
50+
<goal>remap</goal>
51+
</goals>
52+
<id>remap-spigot</id>
53+
<configuration>
54+
<inputFile>target/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
55+
<srgIn>org.spigotmc:minecraft-server:${bukkit.version}:csrg:maps-spigot</srgIn>
56+
<remappedDependencies>org.bukkit:craftbukkit:${bukkit.version}:jar:remapped-obf</remappedDependencies>
57+
</configuration>
58+
</execution>
59+
</executions>
60+
</plugin>
61+
</plugins>
62+
</build>
63+
64+
<dependencies>
65+
<dependency>
66+
<groupId>com.janboerman.invsee</groupId>
67+
<artifactId>invsee-plus-plus_give_common</artifactId>
68+
<version>${project.version}</version>
69+
<scope>provided</scope>
70+
</dependency>
71+
<dependency>
72+
<groupId>com.janboerman.invsee</groupId>
73+
<artifactId>utils</artifactId>
74+
<version>${project.version}</version>
75+
<scope>provided</scope>
76+
</dependency>
77+
<dependency>
78+
<groupId>org.bukkit</groupId>
79+
<artifactId>craftbukkit</artifactId>
80+
<version>${bukkit.version}</version>
81+
<classifier>remapped-mojang</classifier>
82+
<scope>provided</scope>
83+
</dependency>
84+
</dependencies>
85+
86+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.janboerman.invsee.spigot.addon.give.impl_1_21_5_R4;
2+
3+
import com.janboerman.invsee.spigot.addon.give.common.Convert;
4+
import com.janboerman.invsee.spigot.addon.give.common.GiveApi;
5+
import com.janboerman.invsee.spigot.addon.give.common.ItemType;
6+
import com.janboerman.invsee.utils.Either;
7+
import com.mojang.brigadier.exceptions.CommandSyntaxException;
8+
9+
import org.bukkit.inventory.ItemStack;
10+
11+
import net.minecraft.world.Container;
12+
13+
public class GiveImpl implements GiveApi {
14+
15+
public static final GiveImpl INSTANCE = new GiveImpl();
16+
17+
private GiveImpl() {
18+
}
19+
20+
@Override
21+
public ItemStack applyTag(ItemStack stack, String tag) {
22+
if (tag == null) {
23+
return stack;
24+
} else {
25+
throw new IllegalArgumentException("InvSee++ for Minecraft 1.20.5 and up does not support NBT tags on item stacks.");
26+
}
27+
}
28+
29+
@Override
30+
public Either<String, ItemType> parseItemType(String itemType) {
31+
Either<String, ItemType> stackFromLegacySyntax = Convert.convertItemType(itemType);
32+
if (stackFromLegacySyntax.isRight()) {
33+
return stackFromLegacySyntax;
34+
}
35+
36+
try {
37+
return Either.right(new WithComponents(ItemParser.parseItemType(itemType)));
38+
} catch (CommandSyntaxException e) {
39+
return Either.left(e.getMessage());
40+
}
41+
}
42+
43+
@Override
44+
public int maxStackSize() {
45+
return Container.MAX_STACK;
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.janboerman.invsee.spigot.addon.give.impl_1_21_5_R4;
2+
3+
import com.mojang.brigadier.StringReader;
4+
import com.mojang.brigadier.exceptions.CommandSyntaxException;
5+
6+
import net.minecraft.commands.CommandBuildContext;
7+
import net.minecraft.commands.Commands;
8+
import net.minecraft.commands.arguments.item.ItemArgument;
9+
import net.minecraft.commands.arguments.item.ItemInput;
10+
import net.minecraft.core.HolderLookup;
11+
import net.minecraft.server.MinecraftServer;
12+
13+
final class ItemParser {
14+
15+
private static final CommandBuildContext COMMAND_BUILD_CONTEXT = getContext();
16+
17+
private ItemParser() {
18+
}
19+
20+
static ItemInput parseItemType(String text) throws CommandSyntaxException {
21+
ItemArgument argument = new ItemArgument(COMMAND_BUILD_CONTEXT);
22+
ItemInput itemInput = argument.parse(new StringReader(text));
23+
return itemInput;
24+
}
25+
26+
private static CommandBuildContext getContext() {
27+
// HolderLookup.Provider provider = VanillaRegistries.createLookup(); //does not allow access to item components? should I get another one?
28+
HolderLookup.Provider provider = MinecraftServer.getDefaultRegistryAccess(); //can we avoid this deprecated method?
29+
return Commands.createValidationContext(provider);
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.janboerman.invsee.spigot.addon.give.impl_1_21_5_R4;
2+
3+
import com.janboerman.invsee.spigot.addon.give.common.ItemType;
4+
import com.janboerman.invsee.utils.Either;
5+
6+
import com.mojang.brigadier.exceptions.CommandSyntaxException;
7+
8+
import org.bukkit.craftbukkit.v1_21_R4.inventory.CraftItemStack;
9+
import org.bukkit.inventory.ItemStack;
10+
11+
import net.minecraft.commands.arguments.item.ItemInput;
12+
13+
final class WithComponents implements ItemType {
14+
15+
private final ItemInput input;
16+
17+
WithComponents(ItemInput input) {
18+
this.input = input;
19+
}
20+
21+
@Override
22+
public Either<String, ItemStack> toItemStack(int amount) {
23+
try {
24+
return Either.right(CraftItemStack.asCraftMirror(input.createItemStack(amount, false/*don't check stack size*/)));
25+
} catch (CommandSyntaxException e) {
26+
// This shouldn't really ever happen since we never check the count against the max stack size.
27+
return Either.left(e.getMessage());
28+
}
29+
}
30+
}

InvSee++_Give_Plugin/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@
8282
<version>${project.version}</version>
8383
<scope>compile</scope>
8484
</dependency>
85+
<dependency>
86+
<groupId>com.janboerman.invsee</groupId>
87+
<artifactId>give_impl_1_21_5_r4</artifactId>
88+
<version>${project.version}</version>
89+
<scope>compile</scope>
90+
</dependency>
8591
<dependency>
8692
<groupId>com.janboerman.invsee</groupId>
8793
<artifactId>give_impl_1_21_4_r3</artifactId>

InvSee++_Give_Plugin/src/main/java/com/janboerman/invsee/spigot/addon/give/Setup.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ class SetupImpl implements Setup {
4545
SUPPORTED.registerSupportedVersion(() -> new Impl_1_21_1(), ServerSoftware.CRAFTBUKKIT_1_21_1, new ServerSoftware(MinecraftPlatform.PAPER, MinecraftVersion._1_21_1));
4646
SUPPORTED.registerSupportedVersion(() -> new Impl_1_21_3(), ServerSoftware.CRAFTBUKKIT_1_21_3, new ServerSoftware(MinecraftPlatform.PAPER, MinecraftVersion._1_21_3));
4747
SUPPORTED.registerSupportedVersion(() -> new Impl_1_21_4(), ServerSoftware.CRAFTBUKKIT_1_21_4, new ServerSoftware(MinecraftPlatform.PAPER, MinecraftVersion._1_21_4));
48+
SUPPORTED.registerSupportedVersion(() -> new Impl_1_21_5(), ServerSoftware.CRAFTBUKKIT_1_21_5, new ServerSoftware(MinecraftPlatform.PAPER, MinecraftVersion._1_21_5));
4849
final SetupProvider glowstoneProver = () -> new Impl_Glowstone();
4950
final MinecraftVersion[] minecraftVersions = MinecraftVersion.values();
50-
for (int idx = MinecraftVersion._1_8.ordinal(); idx < MinecraftVersion._1_12_2.ordinal(); idx ++) {
51+
for (int idx = MinecraftVersion._1_8.ordinal(); idx < MinecraftVersion._1_12_2.ordinal(); idx++) {
5152
SUPPORTED.registerSupportedVersion(new ServerSoftware(MinecraftPlatform.GLOWSTONE, minecraftVersions[idx]), glowstoneProver);
5253
}
5354
}
@@ -64,6 +65,12 @@ public GiveApi getGiveApi() {
6465
}
6566
}
6667

68+
class Impl_1_21_5 extends SetupImpl {
69+
Impl_1_21_5() {
70+
super(com.janboerman.invsee.spigot.addon.give.impl_1_21_5_R4.GiveImpl.INSTANCE);
71+
}
72+
}
73+
6774
class Impl_1_21_4 extends SetupImpl {
6875
Impl_1_21_4() {
6976
super(com.janboerman.invsee.spigot.addon.give.impl_1_21_4_R3.GiveImpl.INSTANCE);

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<module>InvSee++_Give_Platforms/Give_Impl_1_21_1_R1</module>
4242
<module>InvSee++_Give_Platforms/Give_Impl_1_21_3_R2</module>
4343
<module>InvSee++_Give_Platforms/Give_Impl_1_21_4_R3</module>
44+
<module>InvSee++_Give_Platforms/Give_Impl_1_21_5_R4</module>
4445
<module>InvSee++_Give_Platforms/Give_Impl_Glowstone</module>
4546
<module>InvSee++_Give_Plugin</module>
4647
<module>InvSee++_Clear_Plugin</module>

0 commit comments

Comments
 (0)