Fixed Maven Module System

This commit is contained in:
jameslfc19 2020-07-03 14:23:09 +01:00
parent c90abd1688
commit 6b1a83e1b7
15 changed files with 197 additions and 68 deletions

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.14.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.13-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
</component>
</module>

26
ChestsPlusPlusAPI/pom.xml Normal file
View File

@ -0,0 +1,26 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<artifactId>ChestsPlusPlus-API</artifactId>
<version>1.5-BETA-3</version>
<packaging>jar</packaging>
<parent>
<artifactId>ChestsPlusPlus-Parent</artifactId>
<groupId>com.jamesdpeters.minecraft.chests</groupId>
<version>1.5-BETA-3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -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;
}
}

View File

@ -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<Material> empty = new ArrayList<>();
@Override
protected List<Material> graphically2DList() {
return DEFAULT_ITEMS;
return empty;
}
};
@ -57,12 +59,14 @@ public abstract class MaterialChecker {
protected abstract List<Material> 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();
}
}

15
ChestsPlusPlusParent.iml Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -20,21 +20,12 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="ChestsPlusPlus" />
<orderEntry type="module" module-name="ChestsPlusPlusAPI" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.15-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.4" level="project" />
<orderEntry type="library" name="Maven: org.spigotmc:plugin-annotations:1.2.3-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.bukkit:bukkit:1.13-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" name="Maven: fr.minuskube.inv:smart-invs:1.3.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.bstats:bstats-bukkit:1.7" level="project" />
<orderEntry type="module" module-name="ChestsPlusPlus_1_16" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
</component>
</module>

View File

@ -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">
<parent>
<artifactId>ChestsPlusPlus</artifactId>
<groupId>com.jamesdpeters.chests</groupId>
<artifactId>ChestsPlusPlus-Parent</artifactId>
<groupId>com.jamesdpeters.minecraft.chests</groupId>
<version>1.5-BETA-3</version>
<relativePath>../ChestsPlusPlus_Main/pom.xml</relativePath>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<packaging>jar</packaging>
<artifactId>ChestsPlusPlus_1_15</artifactId>
<repositories>
@ -22,8 +22,8 @@
<dependencies>
<dependency>
<groupId>com.jamesdpeters.chests</groupId>
<artifactId>ChestsPlusPlus</artifactId>
<groupId>com.jamesdpeters.minecraft.chests</groupId>
<artifactId>ChestsPlusPlus-API</artifactId>
<version>1.5-BETA-3</version>
</dependency>

View File

@ -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<Material> 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<Material> graphically2DList() {
return materials;
}
}

View File

@ -21,21 +21,13 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="ChestsPlusPlus_1_16 (1)" />
<orderEntry type="module" module-name="ChestsPlusPlus" />
<orderEntry type="module" module-name="ChestsPlusPlusAPI" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.1" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.4" level="project" />
<orderEntry type="library" name="Maven: org.spigotmc:plugin-annotations:1.2.3-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.bukkit:bukkit:1.13-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" name="Maven: fr.minuskube.inv:smart-invs:1.3.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.bstats:bstats-bukkit:1.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
<orderEntry type="module" module-name="ChestsPlusPlus_1_15" />
</component>
</module>

View File

@ -2,15 +2,16 @@
<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</artifactId>
<groupId>com.jamesdpeters.chests</groupId>
<artifactId>ChestsPlusPlus-Parent</artifactId>
<groupId>com.jamesdpeters.minecraft.chests</groupId>
<version>1.5-BETA-3</version>
<relativePath>../ChestsPlusPlus_Main/pom.xml</relativePath>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<packaging>jar</packaging>
<artifactId>ChestsPlusPlus_1_16</artifactId>
<repositories>
@ -22,10 +23,9 @@
<dependencies>
<dependency>
<groupId>com.jamesdpeters.chests</groupId>
<artifactId>ChestsPlusPlus</artifactId>
<groupId>com.jamesdpeters.minecraft.chests</groupId>
<artifactId>ChestsPlusPlus-API</artifactId>
<version>1.5-BETA-3</version>
<scope>compile</scope>
</dependency>
<dependency>
@ -34,6 +34,12 @@
<version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.jamesdpeters.minecraft.chests</groupId>
<artifactId>ChestsPlusPlus_1_15</artifactId>
<version>1.5-BETA-3</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@ -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<Material> 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

View File

@ -4,8 +4,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jamesdpeters.chests</groupId>
<artifactId>ChestsPlusPlus</artifactId>
<groupId>com.jamesdpeters.minecraft.chests</groupId>
<artifactId>ChestsPlusPlus-Master</artifactId>
<version>1.5-BETA-3</version>
<properties>
@ -21,11 +21,6 @@
</scm>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
@ -87,16 +82,26 @@
</dependency>
<dependency>
<groupId>com.jamesdpeters.chests</groupId>
<groupId>com.jamesdpeters.minecraft.chests</groupId>
<artifactId>ChestsPlusPlus_1_16</artifactId>
<version>1.5-BETA-3</version>
<version>${version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.jamesdpeters.chests</groupId>
<groupId>com.jamesdpeters.minecraft.chests</groupId>
<artifactId>ChestsPlusPlus_1_15</artifactId>
<version>1.5-BETA-3</version>
<version>${version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.jamesdpeters.minecraft.chests</groupId>
<artifactId>ChestsPlusPlus-API</artifactId>
<version>${version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
@ -116,6 +121,7 @@
<includes>
<include>fr.minuskube.inv*:*</include>
<include>org.bstats*:*</include>
<include>com.jamesdpeters.minecraft.chests</include>
</includes>
</artifactSet>
<relocations>
@ -144,7 +150,7 @@
<!--Tell the shade plugin which of it's goals to attempt to run during this phase-->
<configuration>
<!--Tell the shade plugin where to put our jar file-->
<outputFile>${project.basedir}/Server/plugins/${project.artifactId}-${project.version}.jar</outputFile>
<outputFile>../Server/plugins/ChestsPlusPlus-${project.version}.jar</outputFile>
<!-- <minimizeJar>true</minimizeJar>-->
</configuration>
</execution>

View File

@ -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();

View File

@ -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;
}
}

31
pom.xml Normal file
View File

@ -0,0 +1,31 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jamesdpeters.minecraft.chests</groupId>
<artifactId>ChestsPlusPlus-Parent</artifactId>
<version>1.5-BETA-3</version>
<packaging>pom</packaging>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<modules>
<module>ChestsPlusPlusAPI</module>
<module>ChestsPlusPlus_1_16</module>
<module>ChestsPlusPlus_1_15</module>
<module>ChestsPlusPlus_Main</module>
</modules>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
</project>