mirror of
https://github.com/JamesPeters98/ChestsPlusPlus.git
synced 2024-11-14 14:45:36 +01:00
ChestLinks now open!
Added NMS support. Fixed versioning.
This commit is contained in:
parent
c178d982af
commit
367ffdcc73
@ -1,6 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
echo "Checking BuildTools cache"
|
echo "Checking BuildTools cache"
|
||||||
|
|
||||||
|
#Download BuildTools jar
|
||||||
curl -o BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
|
curl -o BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
|
||||||
|
|
||||||
#Local Maven Repo
|
#Local Maven Repo
|
||||||
@ -10,23 +11,19 @@ MAVEN_DIR="$HOME/.m2"
|
|||||||
CRAFTBUKKIT="${MAVEN_DIR}/repository/org/bukkit/craftbukkit"
|
CRAFTBUKKIT="${MAVEN_DIR}/repository/org/bukkit/craftbukkit"
|
||||||
|
|
||||||
#Versions
|
#Versions
|
||||||
#VERSION_1_16="1.16.1"
|
array=("1.16.1" "1.15.2" "1.14.4")
|
||||||
VERSION_1_15="1.15.2"
|
|
||||||
#VERSION_1_14="1.14.4"
|
|
||||||
|
|
||||||
#array=("${VERSION_1_16}" "${VERSION_1_15}" "${VERSION_1_14}")
|
|
||||||
array=("${VERSION_1_15}")
|
|
||||||
|
|
||||||
for i in "${array[@]}"
|
for i in "${array[@]}"
|
||||||
do
|
do
|
||||||
VERSION_DIR="${CRAFTBUKKIT}/${i}-R0.1-SNAPSHOT"
|
VERSION_DIR="${CRAFTBUKKIT}/${i}-R0.1-SNAPSHOT"
|
||||||
|
|
||||||
if [ -d "$VERSION_DIR" ]; then
|
if [ -d "$VERSION_DIR" ]; then
|
||||||
echo "${i} is cached!"
|
echo "CraftBukkit version ${i} is cached!"
|
||||||
else
|
else
|
||||||
echo "${i} isn't cached!"
|
echo "CraftBukkit version ${i} isn't cached!"
|
||||||
echo "Running BuildTools!"
|
echo "Running BuildTools!"
|
||||||
java -jar BuildTools.jar --rev ${i} --compile craftbukkit > /dev/null 2>&1
|
java -jar BuildTools.jar --rev ${i} --compile craftbukkit | awk 'NR <= 3'
|
||||||
echo "Compiled CraftBukkit ${i}"
|
echo "Compiled CraftBukkit ${i}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>ChestsPlusPlus-API</artifactId>
|
<artifactId>ChestsPlusPlus-API</artifactId>
|
||||||
<version>1.5-BETA-3</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>ChestsPlusPlus-Parent</artifactId>
|
<artifactId>ChestsPlusPlus-Parent</artifactId>
|
||||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||||
<version>1.5-BETA-3</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.jamesdpeters.minecraft.chests;
|
||||||
|
|
||||||
|
import org.bukkit.block.Chest;
|
||||||
|
|
||||||
|
public interface ChestOpener {
|
||||||
|
void setLidOpen(Chest chest, boolean open);
|
||||||
|
}
|
47
ChestsPlusPlus_1_14/pom.xml
Normal file
47
ChestsPlusPlus_1_14/pom.xml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?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_14</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>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.14.4-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||||
|
<artifactId>ChestsPlusPlus-API</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>craftbukkit</artifactId>
|
||||||
|
<version>1.14.4-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.jamesdpeters.minecraft.chests;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_14_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_14_R1.TileEntity;
|
||||||
|
import net.minecraft.server.v1_14_R1.TileEntityChest;
|
||||||
|
import net.minecraft.server.v1_14_R1.World;
|
||||||
|
import org.bukkit.block.Chest;
|
||||||
|
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_14_R1.block.CraftChest;
|
||||||
|
|
||||||
|
public class ChestOpener_1_14 implements ChestOpener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLidOpen(Chest chest, boolean open) {
|
||||||
|
CraftChest craftChest = (CraftChest) chest;
|
||||||
|
CraftWorld craftWorld = (CraftWorld) craftChest.getWorld();
|
||||||
|
World world = craftWorld.getHandle();
|
||||||
|
BlockPosition position = craftChest.getPosition();
|
||||||
|
|
||||||
|
TileEntity tileEntity = world.getTileEntity(position);
|
||||||
|
if(tileEntity instanceof TileEntityChest){
|
||||||
|
boolean isCustomTileEntity = tileEntity instanceof CustomTileEntityChest;
|
||||||
|
CustomTileEntityChest customTileEntityChest;
|
||||||
|
if(!isCustomTileEntity){
|
||||||
|
customTileEntityChest = new CustomTileEntityChest();
|
||||||
|
world.removeTileEntity(position);
|
||||||
|
world.setTileEntity(position, customTileEntityChest);
|
||||||
|
} else {
|
||||||
|
customTileEntityChest = (CustomTileEntityChest) tileEntity;
|
||||||
|
}
|
||||||
|
customTileEntityChest.setOpen(open);
|
||||||
|
customTileEntityChest.onOpen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.jamesdpeters.minecraft.chests;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_14_R1.Block;
|
||||||
|
import net.minecraft.server.v1_14_R1.BlockChest;
|
||||||
|
import net.minecraft.server.v1_14_R1.TileEntityChest;
|
||||||
|
|
||||||
|
public class CustomTileEntityChest extends TileEntityChest {
|
||||||
|
|
||||||
|
private int phantomViewers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onOpen() {
|
||||||
|
Block block = this.getBlock().getBlock();
|
||||||
|
if (block instanceof BlockChest) {
|
||||||
|
this.world.playBlockAction(this.position, block, 1, phantomViewers);
|
||||||
|
this.world.applyPhysics(this.position, block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpen(boolean open){
|
||||||
|
if(open) phantomViewers++;
|
||||||
|
else phantomViewers--;
|
||||||
|
if(phantomViewers < 0) phantomViewers = 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.jamesdpeters.minecraft.chests;
|
||||||
|
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_14_R1.TileEntityChest;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.craftbukkit.v1_14_R1.block.CraftChest;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MaterialChecker_1_14 extends MaterialChecker {
|
||||||
|
|
||||||
|
private List<Material> materials;
|
||||||
|
private List<Material> ignoredMaterials;
|
||||||
|
|
||||||
|
public MaterialChecker_1_14(){
|
||||||
|
materials = new ArrayList<>();
|
||||||
|
materials.addAll(version_1_14_Items);
|
||||||
|
|
||||||
|
ignoredMaterials = new ArrayList<>();
|
||||||
|
ignoredMaterials.addAll(version_1_14_Ignored_Items);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Material> graphically2DList() {
|
||||||
|
return materials;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Material> ignoredMaterials() {
|
||||||
|
return ignoredMaterials;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,13 +5,14 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ChestsPlusPlus-Parent</artifactId>
|
<artifactId>ChestsPlusPlus-Parent</artifactId>
|
||||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||||
<version>1.5-BETA-3</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<artifactId>ChestsPlusPlus_1_15</artifactId>
|
<artifactId>ChestsPlusPlus_1_15</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
@ -24,7 +25,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||||
<artifactId>ChestsPlusPlus-API</artifactId>
|
<artifactId>ChestsPlusPlus-API</artifactId>
|
||||||
<version>1.5-BETA-3</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.jamesdpeters.minecraft.chests;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_15_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_15_R1.TileEntity;
|
||||||
|
import net.minecraft.server.v1_15_R1.TileEntityChest;
|
||||||
|
import net.minecraft.server.v1_15_R1.World;
|
||||||
|
import org.bukkit.block.Chest;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.block.CraftChest;
|
||||||
|
|
||||||
|
public class ChestOpener_1_15 implements ChestOpener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLidOpen(Chest chest, boolean open) {
|
||||||
|
CraftChest craftChest = (CraftChest) chest;
|
||||||
|
CraftWorld craftWorld = (CraftWorld) craftChest.getWorld();
|
||||||
|
World world = craftWorld.getHandle();
|
||||||
|
BlockPosition position = craftChest.getPosition();
|
||||||
|
|
||||||
|
TileEntity tileEntity = world.getTileEntity(position);
|
||||||
|
if(tileEntity instanceof TileEntityChest){
|
||||||
|
boolean isCustomTileEntity = tileEntity instanceof CustomTileEntityChest;
|
||||||
|
CustomTileEntityChest customTileEntityChest;
|
||||||
|
if(!isCustomTileEntity){
|
||||||
|
customTileEntityChest = new CustomTileEntityChest();
|
||||||
|
world.removeTileEntity(position);
|
||||||
|
world.setTileEntity(position, customTileEntityChest);
|
||||||
|
} else {
|
||||||
|
customTileEntityChest = (CustomTileEntityChest) tileEntity;
|
||||||
|
}
|
||||||
|
customTileEntityChest.setOpen(open);
|
||||||
|
customTileEntityChest.onOpen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.jamesdpeters.minecraft.chests;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_15_R1.Block;
|
||||||
|
import net.minecraft.server.v1_15_R1.BlockChest;
|
||||||
|
import net.minecraft.server.v1_15_R1.TileEntityChest;
|
||||||
|
|
||||||
|
public class CustomTileEntityChest extends TileEntityChest {
|
||||||
|
|
||||||
|
private int phantomViewers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onOpen() {
|
||||||
|
Block block = this.getBlock().getBlock();
|
||||||
|
if (block instanceof BlockChest) {
|
||||||
|
this.world.playBlockAction(this.position, block, 1, phantomViewers);
|
||||||
|
this.world.applyPhysics(this.position, block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpen(boolean open){
|
||||||
|
if(open) phantomViewers++;
|
||||||
|
else phantomViewers--;
|
||||||
|
if(phantomViewers < 0) phantomViewers = 0;
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,8 @@ package com.jamesdpeters.minecraft.chests;
|
|||||||
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -6,13 +6,14 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ChestsPlusPlus-Parent</artifactId>
|
<artifactId>ChestsPlusPlus-Parent</artifactId>
|
||||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||||
<version>1.5-BETA-3</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<artifactId>ChestsPlusPlus_1_16</artifactId>
|
<artifactId>ChestsPlusPlus_1_16</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
@ -25,7 +26,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||||
<artifactId>ChestsPlusPlus-API</artifactId>
|
<artifactId>ChestsPlusPlus-API</artifactId>
|
||||||
<version>1.5-BETA-3</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -37,9 +38,16 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||||
<artifactId>ChestsPlusPlus_1_15</artifactId>
|
<artifactId>ChestsPlusPlus_1_15</artifactId>
|
||||||
<version>1.5-BETA-3</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>craftbukkit</artifactId>
|
||||||
|
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.jamesdpeters.minecraft.chests;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_16_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_16_R1.TileEntity;
|
||||||
|
import net.minecraft.server.v1_16_R1.TileEntityChest;
|
||||||
|
import net.minecraft.server.v1_16_R1.World;
|
||||||
|
import org.bukkit.block.Chest;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R1.block.CraftChest;
|
||||||
|
|
||||||
|
|
||||||
|
public class ChestOpener_1_16 implements ChestOpener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLidOpen(Chest chest, boolean open) {
|
||||||
|
CraftChest craftChest = (CraftChest) chest;
|
||||||
|
CraftWorld craftWorld = (CraftWorld) craftChest.getWorld();
|
||||||
|
World world = craftWorld.getHandle();
|
||||||
|
BlockPosition position = craftChest.getPosition();
|
||||||
|
|
||||||
|
TileEntity tileEntity = world.getTileEntity(position);
|
||||||
|
if(tileEntity instanceof TileEntityChest){
|
||||||
|
boolean isCustomTileEntity = tileEntity instanceof CustomTileEntityChest;
|
||||||
|
CustomTileEntityChest customTileEntityChest;
|
||||||
|
if(!isCustomTileEntity){
|
||||||
|
customTileEntityChest = new CustomTileEntityChest();
|
||||||
|
world.removeTileEntity(position);
|
||||||
|
world.setTileEntity(position, customTileEntityChest);
|
||||||
|
} else {
|
||||||
|
customTileEntityChest = (CustomTileEntityChest) tileEntity;
|
||||||
|
}
|
||||||
|
customTileEntityChest.setOpen(open);
|
||||||
|
customTileEntityChest.onOpen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.jamesdpeters.minecraft.chests;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_16_R1.Block;
|
||||||
|
import net.minecraft.server.v1_16_R1.BlockChest;
|
||||||
|
import net.minecraft.server.v1_16_R1.TileEntityChest;
|
||||||
|
|
||||||
|
public class CustomTileEntityChest extends TileEntityChest {
|
||||||
|
|
||||||
|
private int phantomViewers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onOpen() {
|
||||||
|
Block block = this.getBlock().getBlock();
|
||||||
|
if (block instanceof BlockChest) {
|
||||||
|
this.world.playBlockAction(this.position, block, 1, phantomViewers);
|
||||||
|
this.world.applyPhysics(this.position, block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpen(boolean open){
|
||||||
|
if(open) phantomViewers++;
|
||||||
|
else phantomViewers--;
|
||||||
|
if(phantomViewers < 0) phantomViewers = 0;
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||||
<artifactId>ChestsPlusPlus-Master</artifactId>
|
<artifactId>ChestsPlusPlus-Master</artifactId>
|
||||||
<version>1.5-BETA-3</version>
|
<version>1.5-BETA-4</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
@ -84,7 +84,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||||
<artifactId>ChestsPlusPlus_1_16</artifactId>
|
<artifactId>ChestsPlusPlus_1_16</artifactId>
|
||||||
<version>${version}</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -92,7 +92,15 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||||
<artifactId>ChestsPlusPlus_1_15</artifactId>
|
<artifactId>ChestsPlusPlus_1_15</artifactId>
|
||||||
<version>${version}</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||||
|
<artifactId>ChestsPlusPlus_1_14</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -100,11 +108,10 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||||
<artifactId>ChestsPlusPlus-API</artifactId>
|
<artifactId>ChestsPlusPlus-API</artifactId>
|
||||||
<version>${version}</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<!--Tell maven how to prepare and build our jar file from our source and dependancies-->
|
<!--Tell maven how to prepare and build our jar file from our source and dependancies-->
|
||||||
|
@ -1,22 +1,29 @@
|
|||||||
package com.jamesdpeters.minecraft.chests.api_interfaces;
|
package com.jamesdpeters.minecraft.chests.api_interfaces;
|
||||||
|
|
||||||
|
import com.jamesdpeters.minecraft.chests.ChestOpener;
|
||||||
|
import com.jamesdpeters.minecraft.chests.ChestOpener_1_14;
|
||||||
|
import com.jamesdpeters.minecraft.chests.ChestOpener_1_15;
|
||||||
|
import com.jamesdpeters.minecraft.chests.ChestOpener_1_16;
|
||||||
import com.jamesdpeters.minecraft.chests.ChestsPlusPlus;
|
import com.jamesdpeters.minecraft.chests.ChestsPlusPlus;
|
||||||
import com.jamesdpeters.minecraft.chests.MaterialChecker;
|
import com.jamesdpeters.minecraft.chests.MaterialChecker;
|
||||||
import com.jamesdpeters.minecraft.chests.MaterialChecker_1_15;
|
import com.jamesdpeters.minecraft.chests.MaterialChecker_1_15;
|
||||||
import com.jamesdpeters.minecraft.chests.MaterialChecker_1_16;
|
import com.jamesdpeters.minecraft.chests.MaterialChecker_1_16;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.block.Chest;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class ApiSpecific {
|
public class ApiSpecific {
|
||||||
|
|
||||||
private static MaterialChecker materialChecker;
|
private static MaterialChecker materialChecker;
|
||||||
|
private static ChestOpener chestOpener;
|
||||||
private static Version version;
|
private static Version version;
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
version = getVersion();
|
version = getVersion();
|
||||||
ChestsPlusPlus.PLUGIN.getLogger().info("Found API version: "+version);
|
ChestsPlusPlus.PLUGIN.getLogger().info("Found API version: "+version);
|
||||||
materialChecker = getMaterialChecker(version);
|
materialChecker = getMaterialChecker(version);
|
||||||
|
chestOpener = getChestOpener(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Version {
|
enum Version {
|
||||||
@ -47,7 +54,21 @@ public class ApiSpecific {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ChestOpener getChestOpener(Version version){
|
||||||
|
switch (version){
|
||||||
|
case API_1_16: return new ChestOpener_1_16();
|
||||||
|
case API_1_15: return new ChestOpener_1_15();
|
||||||
|
case API_1_14: return new ChestOpener_1_14();
|
||||||
|
default: return (chest, open) -> {
|
||||||
|
//Do nothing
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static MaterialChecker getMaterialChecker() {
|
public static MaterialChecker getMaterialChecker() {
|
||||||
return materialChecker;
|
return materialChecker;
|
||||||
}
|
}
|
||||||
|
public static ChestOpener getChestOpener() {
|
||||||
|
return chestOpener;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.jamesdpeters.minecraft.chests.listeners;
|
package com.jamesdpeters.minecraft.chests.listeners;
|
||||||
|
|
||||||
import com.jamesdpeters.minecraft.chests.ChestsPlusPlus;
|
import com.jamesdpeters.minecraft.chests.ChestsPlusPlus;
|
||||||
|
import com.jamesdpeters.minecraft.chests.api_interfaces.ApiSpecific;
|
||||||
import com.jamesdpeters.minecraft.chests.interfaces.VirtualCraftingHolder;
|
import com.jamesdpeters.minecraft.chests.interfaces.VirtualCraftingHolder;
|
||||||
import com.jamesdpeters.minecraft.chests.storage.autocraft.AutoCraftingStorage;
|
import com.jamesdpeters.minecraft.chests.storage.autocraft.AutoCraftingStorage;
|
||||||
import com.jamesdpeters.minecraft.chests.serialize.Config;
|
import com.jamesdpeters.minecraft.chests.serialize.Config;
|
||||||
@ -10,6 +11,9 @@ import com.jamesdpeters.minecraft.chests.misc.Utils;
|
|||||||
import com.jamesdpeters.minecraft.chests.interfaces.VirtualInventoryHolder;
|
import com.jamesdpeters.minecraft.chests.interfaces.VirtualInventoryHolder;
|
||||||
import com.jamesdpeters.minecraft.chests.storage.chestlink.ChestLinkStorage;
|
import com.jamesdpeters.minecraft.chests.storage.chestlink.ChestLinkStorage;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -35,7 +39,7 @@ public class InventoryListener implements Listener {
|
|||||||
if (storage != null) {
|
if (storage != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (event.getPlayer().hasPermission(Permissions.OPEN) && storage.hasPermission((Player) event.getPlayer())) {
|
if (event.getPlayer().hasPermission(Permissions.OPEN) && storage.hasPermission((Player) event.getPlayer())) {
|
||||||
Utils.openChestInventory((Player) event.getPlayer(), storage.getInventory());
|
Utils.openChestInventory((Player) event.getPlayer(), storage, event.getInventory().getLocation());
|
||||||
} else {
|
} else {
|
||||||
Messages.NO_PERMISSION((Player) event.getPlayer());
|
Messages.NO_PERMISSION((Player) event.getPlayer());
|
||||||
}
|
}
|
||||||
@ -63,9 +67,17 @@ public class InventoryListener implements Listener {
|
|||||||
if (holder instanceof VirtualInventoryHolder) {
|
if (holder instanceof VirtualInventoryHolder) {
|
||||||
VirtualInventoryHolder vHolder = (VirtualInventoryHolder) holder;
|
VirtualInventoryHolder vHolder = (VirtualInventoryHolder) holder;
|
||||||
vHolder.openPreviousInventory();
|
vHolder.openPreviousInventory();
|
||||||
if (event.getInventory().getLocation() == null) {
|
Location location = event.getInventory().getLocation();
|
||||||
|
if (location == null) {
|
||||||
Utils.closeInventorySound((Player) event.getPlayer(), event.getInventory());
|
Utils.closeInventorySound((Player) event.getPlayer(), event.getInventory());
|
||||||
}
|
}
|
||||||
|
vHolder.getStorage().getLocations().forEach(locationInfo -> {
|
||||||
|
Block block = locationInfo.getLocation().getBlock();
|
||||||
|
if(block.getState() instanceof Chest){
|
||||||
|
Chest chest = (Chest) block.getState();
|
||||||
|
ApiSpecific.getChestOpener().setLidOpen(chest,false);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if(holder instanceof VirtualCraftingHolder){
|
if(holder instanceof VirtualCraftingHolder){
|
||||||
((VirtualCraftingHolder) holder).stopAnimation();
|
((VirtualCraftingHolder) holder).stopAnimation();
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package com.jamesdpeters.minecraft.chests.misc;
|
package com.jamesdpeters.minecraft.chests.misc;
|
||||||
|
|
||||||
|
import com.jamesdpeters.minecraft.chests.api_interfaces.ApiSpecific;
|
||||||
import com.jamesdpeters.minecraft.chests.filters.Filter;
|
import com.jamesdpeters.minecraft.chests.filters.Filter;
|
||||||
import com.jamesdpeters.minecraft.chests.filters.HopperFilter;
|
import com.jamesdpeters.minecraft.chests.filters.HopperFilter;
|
||||||
|
import com.jamesdpeters.minecraft.chests.storage.chestlink.ChestLinkStorage;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.*;
|
import org.bukkit.block.*;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -16,9 +18,21 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
|
public static void openChestInventory(Player player, ChestLinkStorage storage, Location location){
|
||||||
|
storage.getLocations().forEach(locationInfo -> {
|
||||||
|
if(locationInfo.getLocation() != null){
|
||||||
|
Block block = locationInfo.getLocation().getBlock();
|
||||||
|
if(block.getState() instanceof Chest){
|
||||||
|
Chest chest = (Chest) block.getState();
|
||||||
|
ApiSpecific.getChestOpener().setLidOpen(chest,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
player.openInventory(storage.getInventory());
|
||||||
|
}
|
||||||
|
|
||||||
public static void openChestInventory(Player player, Inventory inventory){
|
public static void openChestInventory(Player player, Inventory inventory){
|
||||||
if(inventory.getLocation() != null) player.getWorld().playSound(inventory.getLocation(), Sound.BLOCK_CHEST_OPEN,0.5f,1f);
|
player.getWorld().playSound(player.getLocation(), Sound.BLOCK_CHEST_OPEN,0.5f,1f);
|
||||||
else player.getWorld().playSound(player.getLocation(), Sound.BLOCK_CHEST_OPEN,0.5f,1f);
|
|
||||||
player.openInventory(inventory);
|
player.openInventory(inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||||
<artifactId>ChestsPlusPlus-Parent</artifactId>
|
<artifactId>ChestsPlusPlus-Parent</artifactId>
|
||||||
<version>1.5-BETA-3</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
Loading…
Reference in New Issue
Block a user