Create Parchment-Common

eden-api was causing issues so I'm moving Parchment's common interfaces and utilities here
This commit is contained in:
lexikiq
2021-05-02 14:31:43 -04:00
parent 140fac2b6c
commit 26f9a018bb
5 changed files with 90 additions and 47 deletions

35
Parchment-Common/pom.xml Normal file
View File

@@ -0,0 +1,35 @@
<?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>parchment-parent</artifactId>
<groupId>me.lexikiq</groupId>
<version>dev-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>parchment-common</artifactId>
<version>dev-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Parchment-Common</name>
<url>https://github.com/lexikiq/Parchment</url>
<description>Common utility files and interfaces for Parchment</description>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations-java5</artifactId>
<version>20.1.0</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,17 @@
package me.lexikiq;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
* Represents an object that has a {@link UUID}
*/
public interface HasUniqueId extends OptionalUniqueId {
/**
* Returns a unique and persistent id for this object
*
* @return unique id
*/
@NotNull UUID getUniqueId(); // named getUniqueId to maintain compatibility with Bukkit
}

View File

@@ -0,0 +1,17 @@
package me.lexikiq;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
/**
* Represents an object that may have a {@link UUID}
*/
public interface OptionalUniqueId {
/**
* Returns a unique and persistent id for this object which may be null
*
* @return unique id or null
*/
@Nullable UUID getUniqueId(); // named getUniqueId to maintain compatibility with Bukkit
}

View File

@@ -1,10 +1,29 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: lexikiq <noellekiq@gmail.com>
Date: Sun, 2 May 2021 00:32:09 -0400
Date: Sun, 2 May 2021 14:16:41 -0400
Subject: [PATCH] Create interfaces for getting UUIDs and Players
Creates new interfaces for getting UUIDs, Human Entities, Offline Players, and Players. Features matching NotNull and Nullable interfaces. Lessens the required overloads for plugin developers when working with varying player objects.
diff --git a/pom.xml b/pom.xml
index e5ed07236c358e9ea544f43b41533c92769192dd..8a45c77963d3cd35d2cfa4a3af15c0e27bbbf165 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,6 +47,14 @@
<!-- Paper end -->
<dependencies>
+ <!-- Parchment start -->
+ <dependency>
+ <groupId>me.lexikiq</groupId>
+ <artifactId>parchment-common</artifactId>
+ <version>dev-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <!-- Parchment end -->
<!-- Paper start -->
<dependency>
<groupId>net.kyori</groupId>
diff --git a/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java b/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java
index 978813b94a5eae0afccbd3b38b463091a46b56ac..18716a020c0c7c1a06b5ab3935abc33a42d89748 100644
--- a/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java
@@ -299,29 +318,6 @@ index 0000000000000000000000000000000000000000..df10bd66eb531f51b519815a67566195
+ @Override
+ @NotNull Player getPlayer();
+}
diff --git a/src/main/java/me/lexikiq/HasUniqueId.java b/src/main/java/me/lexikiq/HasUniqueId.java
new file mode 100644
index 0000000000000000000000000000000000000000..4fe1da41b9417d82f52432c3bd5b4e8b4c73f09b
--- /dev/null
+++ b/src/main/java/me/lexikiq/HasUniqueId.java
@@ -0,0 +1,17 @@
+package me.lexikiq;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.UUID;
+
+/**
+ * Represents an object that has a {@link UUID}
+ */
+public interface HasUniqueId extends OptionalUniqueId {
+ /**
+ * Returns a unique and persistent id for this object
+ *
+ * @return unique id
+ */
+ @NotNull UUID getUniqueId();
+}
diff --git a/src/main/java/me/lexikiq/OptionalHumanEntity.java b/src/main/java/me/lexikiq/OptionalHumanEntity.java
new file mode 100644
index 0000000000000000000000000000000000000000..fc5a565e9b654eaa3604f9be5f0fa86bbaab6f2f
@@ -388,29 +384,6 @@ index 0000000000000000000000000000000000000000..70fcce84e8b42f3a2c3543b8365b25cc
+ */
+ @Nullable Player getPlayer();
+}
diff --git a/src/main/java/me/lexikiq/OptionalUniqueId.java b/src/main/java/me/lexikiq/OptionalUniqueId.java
new file mode 100644
index 0000000000000000000000000000000000000000..da4a0422dd4f072dc15750a9e133262a344ef78a
--- /dev/null
+++ b/src/main/java/me/lexikiq/OptionalUniqueId.java
@@ -0,0 +1,17 @@
+package me.lexikiq;
+
+import org.jetbrains.annotations.Nullable;
+
+import java.util.UUID;
+
+/**
+ * Represents an object that may have a {@link UUID}
+ */
+public interface OptionalUniqueId {
+ /**
+ * Returns a unique and persistent id for this object which may be null
+ *
+ * @return unique id or null
+ */
+ @Nullable UUID getUniqueId();
+}
diff --git a/src/main/java/org/bukkit/OfflinePlayer.java b/src/main/java/org/bukkit/OfflinePlayer.java
index 3afd5f5c0208a4ee93b5dbfc2aab2b9d2e8a7544..e2b4f86fc3825a77a5a0c1c29b428308eee54b16 100644
--- a/src/main/java/org/bukkit/OfflinePlayer.java

View File

@@ -23,6 +23,7 @@
<finalName>${project.artifactId}</finalName>
</build>
<modules>
<module>Parchment-Common</module>
<module>Parchment-API</module>
<module>Parchment-Server</module>
<module>Paper${file.separator}Paper-MojangAPI</module> <!-- We don't plan on patching this, so this hack is good enough. -->