diff --git a/ChestsPlusPlusAPI/ChestsPlusPlusAPI.iml b/ChestsPlusPlusAPI/ChestsPlusPlusAPI.iml new file mode 100644 index 0000000..09c7cef --- /dev/null +++ b/ChestsPlusPlusAPI/ChestsPlusPlusAPI.iml @@ -0,0 +1,30 @@ + + + + + + + SPIGOT + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ChestsPlusPlusAPI/pom.xml b/ChestsPlusPlusAPI/pom.xml new file mode 100644 index 0000000..5c7672a --- /dev/null +++ b/ChestsPlusPlusAPI/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + + ChestsPlusPlus-API + 1.5-BETA-3 + jar + + + ChestsPlusPlus-Parent + com.jamesdpeters.minecraft.chests + 1.5-BETA-3 + ../pom.xml + + + + + org.spigotmc + spigot-api + 1.14.2-R0.1-SNAPSHOT + provided + + + \ No newline at end of file diff --git a/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/API.java b/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/API.java new file mode 100644 index 0000000..471e215 --- /dev/null +++ b/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/API.java @@ -0,0 +1,17 @@ +package com.jamesdpeters.minecraft.chests; + +import org.bukkit.Bukkit; +import org.bukkit.plugin.Plugin; + +public class API { + + private static Plugin plugin; + + public static void register(Plugin plugin){ + API.plugin = plugin; + } + + public static Plugin getPlugin(){ + return plugin; + } +} diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api_interfaces/MaterialChecker.java b/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/MaterialChecker.java similarity index 80% rename from ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api_interfaces/MaterialChecker.java rename to ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/MaterialChecker.java index cc8a2b0..0431b74 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api_interfaces/MaterialChecker.java +++ b/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/MaterialChecker.java @@ -1,9 +1,10 @@ -package com.jamesdpeters.minecraft.chests.api_interfaces; +package com.jamesdpeters.minecraft.chests; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -42,9 +43,10 @@ public abstract class MaterialChecker { ); public static MaterialChecker DEFAULT = new MaterialChecker() { + List empty = new ArrayList<>(); @Override protected List graphically2DList() { - return DEFAULT_ITEMS; + return empty; } }; @@ -57,12 +59,14 @@ public abstract class MaterialChecker { protected abstract List graphically2DList(); /** - * Used to test if an item is graphically a block (e.g a sign is a block but is held like an item.) + * Used to test if an item is graphically 2D (e.g a sign is a block but is held like an item.) * @param itemStack * @return */ public boolean isGraphically2D(ItemStack itemStack){ - return graphically2DList().contains(itemStack.getType()); + if(DEFAULT_ITEMS.contains(itemStack.getType())) return true; + if (graphically2DList().contains(itemStack.getType())) return true; + return itemStack.getType().isBlock(); } } diff --git a/ChestsPlusPlusParent.iml b/ChestsPlusPlusParent.iml new file mode 100644 index 0000000..c035f0b --- /dev/null +++ b/ChestsPlusPlusParent.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ChestsPlusPlus_1_15/ChestsPlusPlus_1_15.iml b/ChestsPlusPlus_1_15/ChestsPlusPlus_1_15.iml index 5d3839d..1f3328e 100644 --- a/ChestsPlusPlus_1_15/ChestsPlusPlus_1_15.iml +++ b/ChestsPlusPlus_1_15/ChestsPlusPlus_1_15.iml @@ -20,21 +20,12 @@ - + - - - + + + - - - - - - - - - - + \ No newline at end of file diff --git a/ChestsPlusPlus_1_15/pom.xml b/ChestsPlusPlus_1_15/pom.xml index 42e73cb..4ccfc59 100644 --- a/ChestsPlusPlus_1_15/pom.xml +++ b/ChestsPlusPlus_1_15/pom.xml @@ -3,14 +3,14 @@ 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"> - ChestsPlusPlus - com.jamesdpeters.chests + ChestsPlusPlus-Parent + com.jamesdpeters.minecraft.chests 1.5-BETA-3 - ../ChestsPlusPlus_Main/pom.xml + ../pom.xml 4.0.0 - pom + jar ChestsPlusPlus_1_15 @@ -22,8 +22,8 @@ - com.jamesdpeters.chests - ChestsPlusPlus + com.jamesdpeters.minecraft.chests + ChestsPlusPlus-API 1.5-BETA-3 diff --git a/ChestsPlusPlus_1_15/src/main/java/com/jamesdpeters/minecraft/chests/MaterialChecker_1_15.java b/ChestsPlusPlus_1_15/src/main/java/com/jamesdpeters/minecraft/chests/MaterialChecker_1_15.java index f336d4e..5d0002a 100644 --- a/ChestsPlusPlus_1_15/src/main/java/com/jamesdpeters/minecraft/chests/MaterialChecker_1_15.java +++ b/ChestsPlusPlus_1_15/src/main/java/com/jamesdpeters/minecraft/chests/MaterialChecker_1_15.java @@ -1,6 +1,6 @@ package com.jamesdpeters.minecraft.chests; -import com.jamesdpeters.minecraft.chests.api_interfaces.MaterialChecker; +import org.bukkit.Bukkit; import org.bukkit.Material; import java.util.ArrayList; @@ -11,9 +11,8 @@ public class MaterialChecker_1_15 extends MaterialChecker { private List materials; - MaterialChecker_1_15(){ + public MaterialChecker_1_15(){ materials = new ArrayList<>(); - materials.addAll(DEFAULT_ITEMS); materials.addAll(Arrays.asList( // Material.DIRT )); @@ -23,4 +22,5 @@ public class MaterialChecker_1_15 extends MaterialChecker { protected List graphically2DList() { return materials; } + } diff --git a/ChestsPlusPlus_1_16/ChestsPlusPlus_1_16.iml b/ChestsPlusPlus_1_16/ChestsPlusPlus_1_16.iml index 8040e34..b0f01ca 100644 --- a/ChestsPlusPlus_1_16/ChestsPlusPlus_1_16.iml +++ b/ChestsPlusPlus_1_16/ChestsPlusPlus_1_16.iml @@ -21,21 +21,13 @@ - + - - - + + + - - - - - - - - - + \ No newline at end of file diff --git a/ChestsPlusPlus_1_16/pom.xml b/ChestsPlusPlus_1_16/pom.xml index b809fd5..6e2a1c8 100644 --- a/ChestsPlusPlus_1_16/pom.xml +++ b/ChestsPlusPlus_1_16/pom.xml @@ -2,15 +2,16 @@ + - ChestsPlusPlus - com.jamesdpeters.chests + ChestsPlusPlus-Parent + com.jamesdpeters.minecraft.chests 1.5-BETA-3 - ../ChestsPlusPlus_Main/pom.xml + ../pom.xml 4.0.0 - pom + jar ChestsPlusPlus_1_16 @@ -22,10 +23,9 @@ - com.jamesdpeters.chests - ChestsPlusPlus + com.jamesdpeters.minecraft.chests + ChestsPlusPlus-API 1.5-BETA-3 - compile @@ -34,6 +34,12 @@ 1.16.1-R0.1-SNAPSHOT provided + + com.jamesdpeters.minecraft.chests + ChestsPlusPlus_1_15 + 1.5-BETA-3 + compile + diff --git a/ChestsPlusPlus_1_16/src/main/java/com/jamesdpeters/minecraft/chests/MaterialChecker_1_16.java b/ChestsPlusPlus_1_16/src/main/java/com/jamesdpeters/minecraft/chests/MaterialChecker_1_16.java index ee0986b..3c2f726 100644 --- a/ChestsPlusPlus_1_16/src/main/java/com/jamesdpeters/minecraft/chests/MaterialChecker_1_16.java +++ b/ChestsPlusPlus_1_16/src/main/java/com/jamesdpeters/minecraft/chests/MaterialChecker_1_16.java @@ -1,8 +1,7 @@ package com.jamesdpeters.minecraft.chests; -import com.jamesdpeters.minecraft.chests.api_interfaces.MaterialChecker; +import org.bukkit.Bukkit; import org.bukkit.Material; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -11,14 +10,14 @@ public class MaterialChecker_1_16 extends MaterialChecker { private List materials; - MaterialChecker_1_16(){ + public MaterialChecker_1_16(){ materials = new ArrayList<>(); - materials.addAll(DEFAULT_ITEMS); //Add previous API additions. materials.addAll(new MaterialChecker_1_15().graphically2DList()); materials.addAll(Arrays.asList( // Material.DIRT )); + API.getPlugin().getLogger().info("Loaded Material Checker 1.16"); } @Override diff --git a/ChestsPlusPlus_Main/pom.xml b/ChestsPlusPlus_Main/pom.xml index 53b4a77..0986077 100644 --- a/ChestsPlusPlus_Main/pom.xml +++ b/ChestsPlusPlus_Main/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.jamesdpeters.chests - ChestsPlusPlus + com.jamesdpeters.minecraft.chests + ChestsPlusPlus-Master 1.5-BETA-3 @@ -21,11 +21,6 @@ - - spigotmc-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - ossrh https://oss.sonatype.org/content/groups/public/ @@ -87,16 +82,26 @@ - com.jamesdpeters.chests + com.jamesdpeters.minecraft.chests ChestsPlusPlus_1_16 - 1.5-BETA-3 + ${version} + jar compile - com.jamesdpeters.chests + com.jamesdpeters.minecraft.chests ChestsPlusPlus_1_15 - 1.5-BETA-3 + ${version} + jar + compile + + + + com.jamesdpeters.minecraft.chests + ChestsPlusPlus-API + ${version} + jar compile @@ -116,6 +121,7 @@ fr.minuskube.inv*:* org.bstats*:* + com.jamesdpeters.minecraft.chests @@ -144,7 +150,7 @@ - ${project.basedir}/Server/plugins/${project.artifactId}-${project.version}.jar + ../Server/plugins/ChestsPlusPlus-${project.version}.jar diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java index 0db41d8..3cbecb2 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java @@ -1,5 +1,6 @@ package com.jamesdpeters.minecraft.chests; +import com.jamesdpeters.minecraft.chests.api_interfaces.ApiSpecific; import com.jamesdpeters.minecraft.chests.commands.AutoCraftCommand; import com.jamesdpeters.minecraft.chests.commands.ChestLinkCommand; import com.jamesdpeters.minecraft.chests.crafting.Crafting; @@ -47,7 +48,7 @@ import org.bukkit.plugin.java.annotation.plugin.author.Author; @Permission(name = Permissions.OPEN, desc = "Gives permission to open ChestLinks!", defaultValue = PermissionDefault.TRUE) @Permission(name = Permissions.MENU, desc = "Gives permission to open the ChestLink menu!", defaultValue = PermissionDefault.TRUE) @Permission(name = Permissions.REMOVE, desc = "Gives permission to remove a ChestLink!", defaultValue = PermissionDefault.TRUE) -@Permission(name = Permissions.OPEN_ANY, desc = "Gives permission to open all chests, for admin use.", defaultValue = PermissionDefault.FALSE) +@Permission(name = Permissions.OPEN_ANY, desc = "Gives permission to open all chests, for admin use.", defaultValue = PermissionDefault.OP) @Permission(name = Permissions.MEMBER, desc = "Gives permission to add/remove a member to/from their chestlink.", defaultValue = PermissionDefault.TRUE) @Permission(name = Permissions.SORT, desc = "Set the sorting option for the given ChestLink.", defaultValue = PermissionDefault.TRUE) @Permission(name = Permissions.AUTOCRAFT_OPEN, desc = "Gives permission to open AutoCrafting stations.", defaultValue = PermissionDefault.TRUE) @@ -78,9 +79,12 @@ public class ChestsPlusPlus extends JavaPlugin { Settings.initConfig(this); Crafting.load(); - PLUGIN = this; + //API initialisation + API.register(this); + ApiSpecific.init(); + //Remove entities that could have been left behind from bad save files/crashes etc. Utils.removeEntities(); diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api_interfaces/APISpecific.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api_interfaces/ApiSpecific.java similarity index 67% rename from ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api_interfaces/APISpecific.java rename to ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api_interfaces/ApiSpecific.java index 2ac3e34..7c769a2 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api_interfaces/APISpecific.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api_interfaces/ApiSpecific.java @@ -1,16 +1,20 @@ package com.jamesdpeters.minecraft.chests.api_interfaces; +import com.jamesdpeters.minecraft.chests.ChestsPlusPlus; +import com.jamesdpeters.minecraft.chests.MaterialChecker; import com.jamesdpeters.minecraft.chests.MaterialChecker_1_15; import com.jamesdpeters.minecraft.chests.MaterialChecker_1_16; import org.bukkit.Bukkit; -public class APISpecific { +public class ApiSpecific { private static MaterialChecker materialChecker; private static Version version; - static { + public static void init(){ version = getVersion(); + ChestsPlusPlus.PLUGIN.getLogger().info("Found API version: "+version); + materialChecker = getMaterialChecker(version); } enum Version { @@ -30,11 +34,15 @@ public class APISpecific { } } - private MaterialChecker getMaterialChecker(Version version){ + private static MaterialChecker getMaterialChecker(Version version){ switch (version){ case API_1_16: return new MaterialChecker_1_16(); case API_1_15: return new MaterialChecker_1_15(); default: return MaterialChecker.DEFAULT; } } + + public static MaterialChecker getMaterialChecker() { + return materialChecker; + } } diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a4d0363 --- /dev/null +++ b/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + com.jamesdpeters.minecraft.chests + ChestsPlusPlus-Parent + 1.5-BETA-3 + pom + + + 8 + 8 + + + + ChestsPlusPlusAPI + ChestsPlusPlus_1_16 + ChestsPlusPlus_1_15 + ChestsPlusPlus_Main + + + + + spigotmc-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + + \ No newline at end of file