mirror of
https://github.com/JamesPeters98/ChestsPlusPlus.git
synced 2024-11-13 06:05:43 +01:00
Update to 1.17 and Java 16.
Also fixes Hopper Filter stack overflow
This commit is contained in:
parent
115c9c2912
commit
111fd8d4df
@ -2,7 +2,10 @@ language: java
|
||||
|
||||
before_install:
|
||||
- cd BuildTools
|
||||
- bash build.sh
|
||||
- jdk_switcher use openjdk8
|
||||
- bash build-pre1.17.sh
|
||||
- jdk_switcher use openjdk16
|
||||
- bash build-1.17+.sh
|
||||
- cd ../
|
||||
|
||||
install:
|
||||
|
31
BuildTools/build-1.17+.sh
Normal file
31
BuildTools/build-1.17+.sh
Normal file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
echo "Checking BuildTools 1.17+ cache"
|
||||
|
||||
#Local Maven Repo
|
||||
MAVEN_DIR="$HOME/.m2"
|
||||
|
||||
#CraftBukkit in local repo
|
||||
CRAFTBUKKIT="${MAVEN_DIR}/repository/org/bukkit/craftbukkit"
|
||||
|
||||
#Versions
|
||||
array=("1.17")
|
||||
|
||||
#Download BuildTools jar
|
||||
curl -s -o BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
|
||||
|
||||
for i in "${array[@]}"
|
||||
do
|
||||
VERSION_DIR="${CRAFTBUKKIT}/${i}-R0.1-SNAPSHOT"
|
||||
|
||||
if [ -d "$VERSION_DIR" ]; then
|
||||
echo "CraftBukkit version ${i} is cached!"
|
||||
echo "Checking for latest commit! "
|
||||
java -jar BuildTools.jar --rev ${i} --compile craftbukkit --compile-if-changed --remapped > /dev/null 2>&1
|
||||
echo "Finished Check."
|
||||
else
|
||||
echo "CraftBukkit version ${i} isn't cached!"
|
||||
echo "Running BuildTools!"
|
||||
java -jar BuildTools.jar --rev ${i} --compile craftbukkit --remapped > /dev/null 2>&1
|
||||
echo "Compiled CraftBukkit ${i}"
|
||||
fi
|
||||
done
|
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
echo "Checking BuildTools cache"
|
||||
echo "Checking BuildTools pre-1.17 cache"
|
||||
|
||||
#Local Maven Repo
|
||||
MAVEN_DIR="$HOME/.m2"
|
@ -15,6 +15,11 @@
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.target>16</maven.compiler.target>
|
||||
<maven.compiler.source>16</maven.compiler.source>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
|
109
ChestsPlusPlus_1_17_R1/pom.xml
Normal file
109
ChestsPlusPlus_1_17_R1/pom.xml
Normal file
@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
<artifactId>ChestsPlusPlus-Parent</artifactId>
|
||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>ChestsPlusPlus_1_17_R1</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigotmc-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||
<artifactId>ChestsPlusPlus-API</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.17-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||
<artifactId>ChestsPlusPlus_1_16</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.17-R0.1-SNAPSHOT</version>
|
||||
<classifier>remapped-mojang</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.17-R0.1-SNAPSHOT</version>
|
||||
<classifier>remapped-mojang</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>specialsource-maven-plugin</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>remap</goal>
|
||||
</goals>
|
||||
<id>remap-obf</id>
|
||||
<configuration>
|
||||
<srgIn>org.spigotmc:minecraft-server:1.17-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
|
||||
<reverse>true</reverse>
|
||||
<remappedDependencies>org.spigotmc:spigot:1.17-R0.1-SNAPSHOT: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>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
|
||||
<srgIn>org.spigotmc:minecraft-server:1.17-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
|
||||
<remappedDependencies>org.spigotmc:spigot:1.17-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>16</source>
|
||||
<target>16</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
@ -0,0 +1,106 @@
|
||||
package com.jamesdpeters.minecraft.chests.v1_17_R1;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.CraftingProvider;
|
||||
import com.jamesdpeters.minecraft.chests.CraftingResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Crafting implements CraftingProvider {
|
||||
|
||||
@Override
|
||||
public CraftingResult craft(World world, List<ItemStack> items) {
|
||||
AbstractContainerMenu container = new AbstractContainerMenu(null, -1) {
|
||||
@Override
|
||||
public InventoryView getBukkitView() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
CraftingContainer crafting = new CraftingContainer(container, 3, 3);
|
||||
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
crafting.setItem(i, CraftItemStack.asNMSCopy(items.get(i)));
|
||||
}
|
||||
|
||||
CraftServer server = (CraftServer) Bukkit.getServer();
|
||||
CraftWorld craftWorld = (CraftWorld) world;
|
||||
Optional<CraftingRecipe> optional = server.getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, crafting, craftWorld.getHandle());
|
||||
|
||||
net.minecraft.world.item.ItemStack itemStack = net.minecraft.world.item.ItemStack.EMPTY;
|
||||
|
||||
if (optional.isPresent()) {
|
||||
CraftingRecipe recipeCrafting = optional.get();
|
||||
itemStack = recipeCrafting.assemble(crafting);
|
||||
}
|
||||
|
||||
CraftingResult result = new CraftingResult();
|
||||
result.setResult(CraftItemStack.asBukkitCopy(itemStack));
|
||||
|
||||
List<ItemStack> matrixResult = crafting.getContents().stream()
|
||||
.map(item -> {
|
||||
Item remainingItem = item.getItem().getCraftingRemainingItem();
|
||||
return remainingItem != null ? CraftItemStack.asBukkitCopy(remainingItem.getDefaultInstance()) : null;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
result.setMatrixResult(matrixResult);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Recipe getRecipe(World world, List<ItemStack> items) {
|
||||
AbstractContainerMenu container = new AbstractContainerMenu(null, -1) {
|
||||
@Override
|
||||
public InventoryView getBukkitView() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CraftingContainer crafting = new CraftingContainer(container, 3, 3);
|
||||
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
if(i >= 9) break; // ItemList cant contain more than 9 items.
|
||||
crafting.setItem(i, CraftItemStack.asNMSCopy(items.get(i)));
|
||||
}
|
||||
|
||||
CraftServer server = (CraftServer) Bukkit.getServer();
|
||||
CraftWorld craftWorld = (CraftWorld) world;
|
||||
Optional<CraftingRecipe> optional = server.getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, crafting, craftWorld.getHandle());
|
||||
|
||||
// var map = server.getServer().getRecipeManager().recipes.get(RecipeType.CRAFTING);
|
||||
//
|
||||
// Optional<CraftingRecipe> recipe = map.values().stream().flatMap(recipe1 -> {
|
||||
// recipe1.matches()
|
||||
// })
|
||||
|
||||
return optional.map(net.minecraft.world.item.crafting.Recipe::toBukkitRecipe).orElse(null);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.jamesdpeters.minecraft.chests.v1_17_R1;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.MaterialChecker;
|
||||
import com.jamesdpeters.minecraft.chests.v1_16_R1.MaterialChecker_1_16;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Only a protocol change from 1.16.2 to 1.16.3 so no new materials were added.
|
||||
*/
|
||||
public class MaterialChecker_1_17_R1 extends MaterialChecker {
|
||||
|
||||
private final MaterialChecker_1_16 version1_16;
|
||||
|
||||
public MaterialChecker_1_17_R1(){
|
||||
version1_16 = new MaterialChecker_1_16();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Material> graphically2DList() {
|
||||
return version1_16.graphically2DList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Material> ignoredMaterials() {
|
||||
return version1_16.ignoredMaterials();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTool(ItemStack itemStack) {
|
||||
return version1_16.isTool(itemStack);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.jamesdpeters.minecraft.chests.v1_17_R1;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.*;
|
||||
import org.bukkit.block.Lidded;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
|
||||
public class NMSProviderImpl implements NMSProvider {
|
||||
|
||||
@Override
|
||||
public ChestOpener getChestOpener() {
|
||||
return (inventory, container, tileEntityOpener) -> {
|
||||
if(hasLiddedAPI()){
|
||||
if(container instanceof Lidded){
|
||||
if(inventory.getViewers().size() > 0){
|
||||
((Lidded) container).open();
|
||||
} else {
|
||||
((Lidded) container).close();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialChecker getMaterialChecker() {
|
||||
return new MaterialChecker_1_17_R1();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftingProvider getCraftingProvider() {
|
||||
return new Crafting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPCProvider getNPCProvider() {
|
||||
return new NPC();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemFrameVisible(ItemFrame itemFrame, boolean visible) {
|
||||
itemFrame.setVisible(visible);
|
||||
}
|
||||
|
||||
private boolean hasLiddedAPI(){
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.jamesdpeters.minecraft.chests.v1_17_R1;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.NPCProvider;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class NPC implements NPCProvider {
|
||||
public HumanEntity createHumanEntity() {
|
||||
MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
|
||||
ServerLevel nmsWorld = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
|
||||
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "Chests++NPC");
|
||||
ServerPlayer npc = new ServerPlayer(nmsServer, nmsWorld, gameProfile);
|
||||
return npc.getBukkitEntity();
|
||||
}
|
||||
}
|
@ -6,11 +6,12 @@
|
||||
|
||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||
<artifactId>ChestsPlusPlus-Master</artifactId>
|
||||
<version>2.4.1-Release</version>
|
||||
<version>2.5-Beta</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.target>16</maven.compiler.target>
|
||||
<maven.compiler.source>16</maven.compiler.source>
|
||||
<maven.compiler.verbose>true</maven.compiler.verbose>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
@ -52,6 +53,13 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>maven-snapshots</id>
|
||||
<url>https://repository.apache.org/content/repositories/snapshots/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
@ -88,7 +96,7 @@
|
||||
<dependency>
|
||||
<groupId>net.wesjd</groupId>
|
||||
<artifactId>anvilgui</artifactId>
|
||||
<version>1.4.0-SNAPSHOT</version>
|
||||
<version>1.5.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -97,6 +105,14 @@
|
||||
<version>1.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||
<artifactId>ChestsPlusPlus_1_17_R1</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||
<artifactId>ChestsPlusPlus_1_16_R3</artifactId>
|
||||
@ -147,7 +163,7 @@
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>RELEASE</version>
|
||||
<version>18.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@ -155,7 +171,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.18</version>
|
||||
<version>1.18.20</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@ -171,7 +187,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
@ -256,6 +272,8 @@
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
|
||||
</plugins>
|
||||
|
||||
<!--Tell maven to enable resource filtering so we can use macros like '${project.version}' inside of our plugin.yml-->
|
||||
|
@ -10,7 +10,6 @@ import com.jamesdpeters.minecraft.chests.serialize.Config;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.PluginConfig;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.SpigotConfig;
|
||||
import com.jamesdpeters.minecraft.chests.storage.chestlink.ChestLinkStorage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -28,6 +27,8 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class HopperListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@ -39,26 +40,28 @@ public class HopperListener implements Listener {
|
||||
if(event.isCancelled()) return;
|
||||
if(event.getDestination().getLocation().getBlock().isBlockPowered()) return;
|
||||
}
|
||||
event.setCancelled(!HopperFilter.isInFilter(event.getDestination().getLocation().getBlock(),event.getItem()));
|
||||
|
||||
Function<ItemStack, Boolean> isFilteredItem = (itemStack ->
|
||||
HopperFilter.isInFilter(event.getDestination().getLocation().getBlock(), itemStack));
|
||||
|
||||
event.setCancelled(!isFilteredItem.apply(event.getItem()));
|
||||
|
||||
// Item shouldn't be allowed
|
||||
if (event.isCancelled() && ServerType.getType() == ServerType.Type.PAPER) {
|
||||
int index = event.getSource().first(event.getItem());
|
||||
int hopperAmount = SpigotConfig.getWorldSettings(event.getSource().getLocation()).getHopperAmount();
|
||||
|
||||
ItemStack item;
|
||||
// Loop until next item is found, if no item found return.
|
||||
while ((item = event.getSource().getItem(++index)) == null) {
|
||||
if (index >= event.getSource().getSize() - 1)
|
||||
// Loop over the inventory until next item is found, if no item found return.
|
||||
while (true) {
|
||||
ItemStack item = event.getSource().getItem(index++);
|
||||
|
||||
if (index >= event.getSource().getSize())
|
||||
return;
|
||||
}
|
||||
|
||||
InventoryMoveItemEvent newEvent =
|
||||
new InventoryMoveItemEvent(event.getSource(), item, event.getDestination(), true);
|
||||
Bukkit.getPluginManager().callEvent(newEvent);
|
||||
|
||||
if (!newEvent.isCancelled()) {
|
||||
int hopperAmount = SpigotConfig.getWorldSettings(event.getSource().getLocation()).getHopperAmount();
|
||||
Utils.hopperMove(event.getSource(), item, hopperAmount, event.getDestination());
|
||||
if (isFilteredItem.apply(item)) {
|
||||
Utils.hopperMove(event.getSource(), item, hopperAmount, event.getDestination());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,13 +19,7 @@ import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class StorageUtils<T extends StorageInfo<S>, S extends AbstractStorage> {
|
||||
|
||||
private final StorageType<S> storageType;
|
||||
|
||||
public StorageUtils(StorageType<S> storageType) {
|
||||
this.storageType = storageType;
|
||||
}
|
||||
public record StorageUtils<T extends StorageInfo<S>, S extends AbstractStorage>(StorageType<S> storageType) {
|
||||
|
||||
public StorageInfo<S> getStorageInfo(Sign sign, String[] lines, UUID uuid) {
|
||||
if (lines != null) {
|
||||
@ -71,13 +65,11 @@ public class StorageUtils<T extends StorageInfo<S>, S extends AbstractStorage> {
|
||||
if (face == null) return null;
|
||||
Block sign = block.getRelative(face);
|
||||
|
||||
if (sign.getBlockData() instanceof Directional) {
|
||||
if (sign.getBlockData() instanceof Directional directional) {
|
||||
//Check if the sign is attached to the given block.
|
||||
Directional directional = (Directional) sign.getBlockData();
|
||||
if (directional.getFacing() != face) return null;
|
||||
//If it is we can extract info from it.
|
||||
if (sign.getState() instanceof Sign) {
|
||||
Sign s = (Sign) sign.getState();
|
||||
if (sign.getState() instanceof Sign s) {
|
||||
return getStorageInfo(s);
|
||||
}
|
||||
}
|
||||
@ -93,8 +85,7 @@ public class StorageUtils<T extends StorageInfo<S>, S extends AbstractStorage> {
|
||||
*/
|
||||
public boolean isValidSignPosition(Location location) {
|
||||
Block block = location.getBlock();
|
||||
if (block.getBlockData() instanceof Directional) {
|
||||
Directional sign = (Directional) block.getBlockData();
|
||||
if (block.getBlockData() instanceof Directional sign) {
|
||||
BlockFace facing = sign.getFacing().getOppositeFace();
|
||||
Block toTest = block.getRelative(facing);
|
||||
|
||||
@ -105,7 +96,7 @@ public class StorageUtils<T extends StorageInfo<S>, S extends AbstractStorage> {
|
||||
if (!storageType.isValidBlockType(toTest)) return false;
|
||||
|
||||
//Check if block placed against is already part of this group.
|
||||
StorageInfo info = getStorageInfo(toTest.getLocation());
|
||||
StorageInfo<S> info = getStorageInfo(toTest.getLocation());
|
||||
return (info == null);
|
||||
}
|
||||
return false;
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Chests++ Language File (Version 2.4.1-Release)
|
||||
# Chests++ Language File (Version 2.5-Release)
|
||||
# NOTE: This file gets replaced when the plugin launches! If you want to make modifications create a copy first!
|
||||
# To create a new language file simply create a copy of this file and rename it to your desired choice for example 'en_US.properties'
|
||||
# It should be located in the 'lang' folder
|
||||
|
Loading…
Reference in New Issue
Block a user