-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f68c8a0
commit 46d71a6
Showing
40 changed files
with
4,793 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<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"> | ||
<parent> | ||
<relativePath>../../pom.xml</relativePath> | ||
<groupId>com.janboerman.invsee</groupId> | ||
<artifactId>invsee-plus-plus</artifactId> | ||
<version>0.27.1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>give_impl_1_21_r1</artifactId> | ||
<name>InvSee++ Give implementation for CraftBukkit 1.21</name> | ||
|
||
<properties> | ||
<bukkit.version>1.21-R0.1-SNAPSHOT</bukkit.version> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${maven-compiler-plugin.version}</version> | ||
<configuration> | ||
<release>21</release> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>net.md-5</groupId> | ||
<artifactId>specialsource-maven-plugin</artifactId> | ||
<version>${specialsource-maven-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>remap</goal> | ||
</goals> | ||
<id>remap-obf</id> | ||
<configuration> | ||
<srgIn>org.spigotmc:minecraft-server:${bukkit.version}:txt:maps-mojang</srgIn> | ||
<reverse>true</reverse> | ||
<remappedDependencies>org.bukkit:craftbukkit:${bukkit.version}:jar:remapped-mojang</remappedDependencies> | ||
<remappedArtifactAttached>true</remappedArtifactAttached> | ||
<remappedClassifierName>remapped-obf</remappedClassifierName> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>remap</goal> | ||
</goals> | ||
<id>remap-spigot</id> | ||
<configuration> | ||
<inputFile>target/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile> | ||
<srgIn>org.spigotmc:minecraft-server:${bukkit.version}:csrg:maps-spigot</srgIn> | ||
<remappedDependencies>org.bukkit:craftbukkit:${bukkit.version}:jar:remapped-obf</remappedDependencies> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<repositories> | ||
<repository> | ||
<id>jitpack.io</id> | ||
<url>https://jitpack.io</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.janboerman.invsee</groupId> | ||
<artifactId>invsee-plus-plus_give_common</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.janboerman.invsee</groupId> | ||
<artifactId>utils</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.TheNullicorn</groupId> | ||
<artifactId>Nedit</artifactId> | ||
<version>49615cf47c</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.bukkit</groupId> | ||
<artifactId>craftbukkit</artifactId> | ||
<version>${bukkit.version}</version> | ||
<classifier>remapped-mojang</classifier> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
47 changes: 47 additions & 0 deletions
47
..._1_21_R1/src/main/java/com/janboerman/invsee/spigot/addon/give/impl_1_21_R1/GiveImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.janboerman.invsee.spigot.addon.give.impl_1_21_R1; | ||
|
||
import com.janboerman.invsee.spigot.addon.give.common.Convert; | ||
import com.janboerman.invsee.spigot.addon.give.common.GiveApi; | ||
import com.janboerman.invsee.spigot.addon.give.common.ItemType; | ||
import com.janboerman.invsee.utils.Either; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
|
||
import org.bukkit.inventory.ItemStack; | ||
|
||
import net.minecraft.world.Container; | ||
|
||
public class GiveImpl implements GiveApi { | ||
|
||
public static final GiveImpl INSTANCE = new GiveImpl(); | ||
|
||
private GiveImpl() { | ||
} | ||
|
||
@Override | ||
public ItemStack applyTag(ItemStack stack, String tag) { | ||
if (tag == null) { | ||
return stack; | ||
} else { | ||
throw new IllegalArgumentException("InvSee++ for Minecraft 1.20.5 and up does not support NBT tags on item stacks."); | ||
} | ||
} | ||
|
||
@Override | ||
public Either<String, ItemType> parseItemType(String itemType) { | ||
Either<String, ItemType> stackFromLegacySyntax = Convert.convertItemType(itemType); | ||
if (stackFromLegacySyntax.isRight()) { | ||
return stackFromLegacySyntax; | ||
} | ||
|
||
try { | ||
return Either.right(new WithComponents(ItemParser.parseItemType(itemType))); | ||
} catch (CommandSyntaxException e) { | ||
return Either.left(e.getMessage()); | ||
} | ||
} | ||
|
||
@Override | ||
public int maxStackSize() { | ||
return Container.MAX_STACK; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
..._21_R1/src/main/java/com/janboerman/invsee/spigot/addon/give/impl_1_21_R1/ItemParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.janboerman.invsee.spigot.addon.give.impl_1_21_R1; | ||
|
||
import java.util.Optional; | ||
import java.util.stream.Stream; | ||
|
||
import com.mojang.brigadier.StringReader; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
|
||
import net.minecraft.commands.CommandBuildContext; | ||
import net.minecraft.commands.arguments.item.ItemArgument; | ||
import net.minecraft.commands.arguments.item.ItemInput; | ||
import net.minecraft.core.HolderLookup; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.data.registries.VanillaRegistries; | ||
import net.minecraft.resources.ResourceKey; | ||
|
||
final class ItemParser { | ||
|
||
private static final CommandBuildContext COMMAND_BUILD_CONTEXT = getContext(); | ||
|
||
private ItemParser() { | ||
} | ||
|
||
static ItemInput parseItemType(String text) throws CommandSyntaxException { | ||
ItemArgument argument = new ItemArgument(COMMAND_BUILD_CONTEXT); | ||
ItemInput itemInput = argument.parse(new StringReader(text)); | ||
return itemInput; | ||
} | ||
|
||
private static CommandBuildContext getContext() { | ||
HolderLookup.Provider provider = VanillaRegistries.createLookup(); | ||
|
||
return new CommandBuildContext() { | ||
@Override | ||
public Stream<ResourceKey<? extends Registry<?>>> listRegistries() { | ||
return provider.listRegistries(); | ||
} | ||
|
||
@Override | ||
public <T> Optional<HolderLookup.RegistryLookup<T>> lookup(ResourceKey<? extends Registry<? extends T>> resourceKey) { | ||
return provider.lookup(resourceKey); | ||
} | ||
}; | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...R1/src/main/java/com/janboerman/invsee/spigot/addon/give/impl_1_21_R1/WithComponents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.janboerman.invsee.spigot.addon.give.impl_1_21_R1; | ||
|
||
import com.janboerman.invsee.spigot.addon.give.common.ItemType; | ||
import com.janboerman.invsee.utils.Either; | ||
|
||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
|
||
import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
import net.minecraft.commands.arguments.item.ItemInput; | ||
|
||
final class WithComponents implements ItemType { | ||
|
||
private final ItemInput input; | ||
|
||
WithComponents(ItemInput input) { | ||
this.input = input; | ||
} | ||
|
||
@Override | ||
public Either<String, ItemStack> toItemStack(int amount) { | ||
try { | ||
return Either.right(CraftItemStack.asCraftMirror(input.createItemStack(amount, false/*don't check stack size*/))); | ||
} catch (CommandSyntaxException e) { | ||
// This shouldn't really ever happen since we never check the count against the max stack size. | ||
return Either.left(e.getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.