Skip to content

Commit c248c8e

Browse files
authored
Merge pull request #178 from Jannyboy11/feature/native-paper
Adds compatibility modules specificly for Paper.
2 parents 4d44ddb + 3077708 commit c248c8e

File tree

37 files changed

+3751
-4
lines changed

37 files changed

+3751
-4
lines changed

.github/workflows/compile.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ jobs:
5555
java -jar BuildTools.jar --rev 4522 --compile craftbukkit --remapped
5656
java -jar BuildTools.jar --rev 4539 --compile craftbukkit --remapped
5757
java -jar BuildTools.jar --rev 1.21.11 --compile craftbukkit --remapped
58+
- name: Install Paper 1.21.11
59+
run: |
60+
mvn ca.bkaw:paper-nms-maven-plugin:init --pl :impl_paper_1_21_11
5861
- name: Compile InvSee++
5962
run: mvn clean package install --batch-mode --update-snapshots
6063
- name: Create tagged release

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#Maven
88
target/*
99

10+
#paper-nms-maven-plugin
11+
**/.paper-nms
12+
1013
#Eclipse
1114
**/.settings/*
1215
**/.project

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class ServerSoftware {
3030
CRAFTBUKKIT_1_21_9 = new ServerSoftware(CRAFTBUKKIT, _1_21_9),
3131
CRAFTBUKKIT_1_21_10 = new ServerSoftware(CRAFTBUKKIT, _1_21_10),
3232
CRAFTBUKKIT_1_21_11 = new ServerSoftware(CRAFTBUKKIT, _1_21_11),
33+
PAPER_1_21_11 = new ServerSoftware(PAPER, _1_21_11),
3334
GLOWSTONE_1_8_8 = new ServerSoftware(GLOWSTONE, _1_8_8),
3435
GLOWSTONE_1_8_9 = new ServerSoftware(GLOWSTONE, _1_8_9),
3536
GLOWSTONE_1_12_2 = new ServerSoftware(GLOWSTONE, _1_12_2);

InvSee++_Give_Platforms/Give_Impl_1_21_11_R7/src/main/java/com/janboerman/invsee/spigot/addon/give/impl_1_21_11_R7/ItemParser.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import com.mojang.brigadier.StringReader;
44
import com.mojang.brigadier.exceptions.CommandSyntaxException;
55

6-
import org.bukkit.craftbukkit.v1_21_R7.inventory.CraftItemFactory;
7-
86
import net.minecraft.commands.CommandBuildContext;
97
import net.minecraft.commands.Commands;
108
import net.minecraft.commands.arguments.item.ItemArgument;
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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.30.14-SNAPSHOT</version>
7+
</parent>
8+
<modelVersion>4.0.0</modelVersion>
9+
10+
<artifactId>give_impl_paper_1_21_11</artifactId>
11+
<name>InvSee++ Give implementation for Paper 1.21.11</name>
12+
13+
<properties>
14+
<paper.version>1.21.11-SNAPSHOT</paper.version>
15+
<paper-api.version>1.21.11-R0.1-SNAPSHOT</paper-api.version>
16+
</properties>
17+
18+
<pluginRepositories>
19+
<pluginRepository>
20+
<id>bytecode.space</id>
21+
<url>https://repo.bytecode.space/repository/maven-public/</url>
22+
</pluginRepository>
23+
</pluginRepositories>
24+
25+
<build>
26+
<plugins>
27+
<plugin>
28+
<groupId>org.apache.maven.plugins</groupId>
29+
<artifactId>maven-compiler-plugin</artifactId>
30+
<version>${maven-compiler-plugin.version}</version>
31+
<configuration>
32+
<release>21</release>
33+
</configuration>
34+
</plugin>
35+
</plugins>
36+
</build>
37+
38+
<repositories>
39+
<repository>
40+
<id>papermc</id>
41+
<url>https://repo.papermc.io/repository/maven-public/</url>
42+
</repository>
43+
</repositories>
44+
45+
<dependencies>
46+
<dependency>
47+
<groupId>io.papermc.paper</groupId>
48+
<artifactId>paper-api</artifactId>
49+
<version>${paper-api.version}</version>
50+
<scope>provided</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>com.janboerman.invsee</groupId>
54+
<artifactId>invsee-plus-plus_give_common</artifactId>
55+
<version>${project.version}</version>
56+
<scope>provided</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>com.janboerman.invsee</groupId>
60+
<artifactId>utils</artifactId>
61+
<version>${project.version}</version>
62+
<scope>provided</scope>
63+
</dependency>
64+
<dependency>
65+
<groupId>ca.bkaw</groupId>
66+
<artifactId>paper-nms</artifactId>
67+
<version>${paper.version}</version>
68+
<scope>provided</scope>
69+
</dependency>
70+
</dependencies>
71+
72+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.janboerman.invsee.paper.addon.give.impl_1_21_11;
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+
import net.minecraft.world.Container;
9+
import org.bukkit.inventory.ItemStack;
10+
11+
public class GiveImpl implements GiveApi {
12+
13+
public static final GiveImpl INSTANCE = new GiveImpl();
14+
15+
private GiveImpl() {
16+
}
17+
18+
@Override
19+
public ItemStack applyTag(ItemStack stack, String tag) {
20+
if (tag == null) {
21+
return stack;
22+
} else {
23+
throw new IllegalArgumentException("InvSee++ for Minecraft 1.20.5 and up does not support NBT tags on item stacks.");
24+
}
25+
}
26+
27+
@Override
28+
public Either<String, ItemType> parseItemType(String itemType) {
29+
Either<String, ItemType> stackFromLegacySyntax = Convert.convertItemType(itemType);
30+
if (stackFromLegacySyntax.isRight()) {
31+
return stackFromLegacySyntax;
32+
}
33+
34+
try {
35+
return Either.right(new WithComponents(ItemParser.parseItemType(itemType)));
36+
} catch (CommandSyntaxException e) {
37+
return Either.left(e.getMessage());
38+
}
39+
}
40+
41+
@Override
42+
public int maxStackSize() {
43+
return Container.MAX_STACK;
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.janboerman.invsee.paper.addon.give.impl_1_21_11;
2+
3+
import com.mojang.brigadier.StringReader;
4+
import com.mojang.brigadier.exceptions.CommandSyntaxException;
5+
import net.minecraft.commands.CommandBuildContext;
6+
import net.minecraft.commands.Commands;
7+
import net.minecraft.commands.arguments.item.ItemArgument;
8+
import net.minecraft.commands.arguments.item.ItemInput;
9+
import net.minecraft.core.HolderLookup;
10+
import org.bukkit.craftbukkit.CraftRegistry;
11+
12+
final class ItemParser {
13+
14+
private static final CommandBuildContext COMMAND_BUILD_CONTEXT = getContext();
15+
16+
private ItemParser() {
17+
}
18+
19+
static ItemInput parseItemType(String text) throws CommandSyntaxException {
20+
// Could be using CraftItemFactory to create an ItemStack from a string directly?
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 = CraftRegistry.getMinecraftRegistry();
28+
return Commands.createValidationContext(provider);
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.janboerman.invsee.paper.addon.give.impl_1_21_11;
2+
3+
import com.janboerman.invsee.spigot.addon.give.common.ItemType;
4+
import com.janboerman.invsee.utils.Either;
5+
import com.mojang.brigadier.exceptions.CommandSyntaxException;
6+
import net.minecraft.commands.arguments.item.ItemInput;
7+
import org.bukkit.craftbukkit.inventory.CraftItemStack;
8+
import org.bukkit.inventory.ItemStack;
9+
10+
final class WithComponents implements ItemType {
11+
12+
private final ItemInput input;
13+
14+
WithComponents(ItemInput input) {
15+
this.input = input;
16+
}
17+
18+
@Override
19+
public Either<String, ItemStack> toItemStack(int amount) {
20+
try {
21+
return Either.right(CraftItemStack.asCraftMirror(input.createItemStack(amount, false/*don't check stack size*/)));
22+
} catch (CommandSyntaxException e) {
23+
// This shouldn't really ever happen since we never check the count against the max stack size.
24+
return Either.left(e.getMessage());
25+
}
26+
}
27+
}

InvSee++_Give_Plugin/pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@
3939
</execution>
4040
</executions>
4141
</plugin>
42+
43+
<plugin>
44+
<groupId>org.apache.maven.plugins</groupId>
45+
<artifactId>maven-jar-plugin</artifactId>
46+
<version>${maven-jar-plugin.version}</version>
47+
<configuration>
48+
<archive>
49+
<manifestEntries>
50+
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
51+
</manifestEntries>
52+
</archive>
53+
</configuration>
54+
</plugin>
55+
4256
</plugins>
4357

4458
<resources>
@@ -88,6 +102,12 @@
88102
<version>${project.version}</version>
89103
<scope>compile</scope>
90104
</dependency>
105+
<dependency>
106+
<groupId>com.janboerman.invsee</groupId>
107+
<artifactId>give_impl_paper_1_21_11</artifactId>
108+
<version>${project.version}</version>
109+
<scope>compile</scope>
110+
</dependency>
91111
<dependency>
92112
<groupId>com.janboerman.invsee</groupId>
93113
<artifactId>give_impl_1_21_9_r6</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
@@ -47,7 +47,8 @@ class SetupImpl implements Setup {
4747
SUPPORTED.registerSupportedVersion(() -> new Impl_1_21_5(), ServerSoftware.CRAFTBUKKIT_1_21_5, new ServerSoftware(MinecraftPlatform.PAPER, MinecraftVersion._1_21_5));
4848
SUPPORTED.registerSupportedVersion(() -> new Impl_1_21_7(), ServerSoftware.CRAFTBUKKIT_1_21_7, ServerSoftware.CRAFTBUKKIT_1_21_8, new ServerSoftware(MinecraftPlatform.PAPER, MinecraftVersion._1_21_7), new ServerSoftware(MinecraftPlatform.PAPER, MinecraftVersion._1_21_8));
4949
SUPPORTED.registerSupportedVersion(() -> new Impl_1_21_9(), ServerSoftware.CRAFTBUKKIT_1_21_9, ServerSoftware.CRAFTBUKKIT_1_21_10, new ServerSoftware(MinecraftPlatform.PAPER, MinecraftVersion._1_21_9), new ServerSoftware(MinecraftPlatform.PAPER, MinecraftVersion._1_21_10));
50-
SUPPORTED.registerSupportedVersion(() -> new Impl_1_21_11(), ServerSoftware.CRAFTBUKKIT_1_21_11, new ServerSoftware(MinecraftPlatform.PAPER, MinecraftVersion._1_21_11));
50+
SUPPORTED.registerSupportedVersion(() -> new Impl_1_21_11(), ServerSoftware.CRAFTBUKKIT_1_21_11);
51+
SUPPORTED.registerSupportedVersion(() -> new Impl_Paper_1_21_11(), ServerSoftware.PAPER_1_21_11);
5152
final SetupProvider glowstoneProver = () -> new Impl_Glowstone();
5253
final MinecraftVersion[] minecraftVersions = MinecraftVersion.values();
5354
for (int idx = MinecraftVersion._1_8.ordinal(); idx < MinecraftVersion._1_12_2.ordinal(); idx++) {
@@ -73,6 +74,12 @@ class Impl_1_21_11 extends SetupImpl {
7374
}
7475
}
7576

77+
class Impl_Paper_1_21_11 extends SetupImpl {
78+
Impl_Paper_1_21_11() {
79+
super(com.janboerman.invsee.paper.addon.give.impl_1_21_11.GiveImpl.INSTANCE);
80+
}
81+
}
82+
7683
class Impl_1_21_9 extends SetupImpl {
7784
Impl_1_21_9() {
7885
super(com.janboerman.invsee.spigot.addon.give.impl_1_21_9_R6.GiveImpl.INSTANCE);

0 commit comments

Comments
 (0)