Basic paperweight init
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: lexikiq <noellekiq@gmail.com>
|
||||
Date: Sat, 1 May 2021 14:27:26 -0400
|
||||
Subject: [PATCH] Parchment POM Changes
|
||||
|
||||
|
||||
diff --git a/pom.xml b/pom.xml
|
||||
index 73fbd5d5a591871a3a386fb5c455cd96a3992e7a..1e182b441771c7159dd4323c2c72364efb971407 100644
|
||||
--- a/pom.xml
|
||||
+++ b/pom.xml
|
||||
@@ -3,18 +3,18 @@
|
||||
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>
|
||||
<parent>
|
||||
- <groupId>com.destroystokyo.paper</groupId>
|
||||
- <artifactId>paper-parent</artifactId>
|
||||
+ <groupId>me.lexikiq</groupId>
|
||||
+ <artifactId>parchment-parent</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
+ <relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
- <groupId>com.destroystokyo.paper</groupId>
|
||||
- <artifactId>paper-api</artifactId>
|
||||
+ <artifactId>parchment-api</artifactId>
|
||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
- <name>Paper-API</name>
|
||||
- <url>https://github.com/PaperMC/Paper</url>
|
||||
+ <name>Parchment-API</name>
|
||||
+ <url>https://github.com/lexikiq/Parchment</url>
|
||||
<description>An enhanced plugin API for Minecraft servers.</description>
|
||||
|
||||
<properties>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,83 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: lexikiq <noellekiq@gmail.com>
|
||||
Date: Mon, 3 May 2021 21:48:40 -0400
|
||||
Subject: [PATCH] Add [Optional]PlayerLike interfaces
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/lexikiq/OptionalPlayerLike.java b/src/main/java/me/lexikiq/OptionalPlayerLike.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..aaa1879f9560ef6ff415e98a5fdf2403f0480a0b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/lexikiq/OptionalPlayerLike.java
|
||||
@@ -0,0 +1,16 @@
|
||||
+package me.lexikiq;
|
||||
+
|
||||
+import net.kyori.adventure.identity.Identified;
|
||||
+import net.kyori.adventure.identity.Identity;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+
|
||||
+/**
|
||||
+ * Class that may be like a {@link org.bukkit.entity.Player} in that it has a {@link java.util.UUID}, {@link org.bukkit.OfflinePlayer}, {@link Identity}, and a nullable Player.
|
||||
+ * @see me.lexikiq.PlayerLike
|
||||
+ */
|
||||
+public interface OptionalPlayerLike extends OptionalPlayer, HasUniqueId, HasOfflinePlayer, Identified {
|
||||
+ @Override
|
||||
+ default @NonNull Identity identity() {
|
||||
+ return Identity.identity(getUniqueId());
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/lexikiq/PlayerLike.java b/src/main/java/me/lexikiq/PlayerLike.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3184f585f9c6e59ce9297d6613749453ce5e6ab5
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/lexikiq/PlayerLike.java
|
||||
@@ -0,0 +1,7 @@
|
||||
+package me.lexikiq;
|
||||
+
|
||||
+/**
|
||||
+ * Class that is like a {@link org.bukkit.entity.Player} in that it has a Player, {@link java.util.UUID}, {@link org.bukkit.OfflinePlayer}, and an {@link net.kyori.adventure.identity.Identity}.
|
||||
+ * @see me.lexikiq.OptionalPlayerLike
|
||||
+ */
|
||||
+public interface PlayerLike extends HasPlayer, OptionalPlayerLike {}
|
||||
diff --git a/src/main/java/org/bukkit/OfflinePlayer.java b/src/main/java/org/bukkit/OfflinePlayer.java
|
||||
index e2b4f86fc3825a77a5a0c1c29b428308eee54b16..95220ef8ad0602fae9f88c0231762ff50358d98f 100644
|
||||
--- a/src/main/java/org/bukkit/OfflinePlayer.java
|
||||
+++ b/src/main/java/org/bukkit/OfflinePlayer.java
|
||||
@@ -5,6 +5,7 @@ import java.util.UUID;
|
||||
import me.lexikiq.HasOfflinePlayer;
|
||||
import me.lexikiq.HasUniqueId;
|
||||
import me.lexikiq.OptionalPlayer;
|
||||
+import me.lexikiq.OptionalPlayerLike;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -13,7 +14,7 @@ import org.bukkit.permissions.ServerOperator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
-public interface OfflinePlayer extends ServerOperator, AnimalTamer, ConfigurationSerializable, OptionalPlayer, HasUniqueId, HasOfflinePlayer { // Parchment
|
||||
+public interface OfflinePlayer extends ServerOperator, AnimalTamer, ConfigurationSerializable, OptionalPlayerLike { // Parchment
|
||||
// Parchment start
|
||||
@Override
|
||||
@NotNull default OfflinePlayer getOfflinePlayer() {
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 54138dae452714e73549ad1c1512b68267cad443..2c9aa0cbce1450695b285a9e654b0e9f10e28c37 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -6,6 +6,7 @@ import java.util.UUID;
|
||||
import com.destroystokyo.paper.ClientOption; // Paper
|
||||
import com.destroystokyo.paper.Title; // Paper
|
||||
import me.lexikiq.HasPlayer;
|
||||
+import me.lexikiq.PlayerLike;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import com.destroystokyo.paper.profile.PlayerProfile; // Paper
|
||||
import java.util.Date; // Paper
|
||||
@@ -40,7 +41,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* Represents a player, connected or not
|
||||
*/
|
||||
-public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, com.destroystokyo.paper.network.NetworkClient, HasPlayer { // Paper // Parchment
|
||||
+public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, com.destroystokyo.paper.network.NetworkClient, PlayerLike { // Paper // Parchment
|
||||
|
||||
// Parchment start
|
||||
/**
|
||||
@@ -1,80 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: lexikiq <noellekiq@gmail.com>
|
||||
Date: Sun, 9 May 2021 17:03:09 -0400
|
||||
Subject: [PATCH] Update to Java 15
|
||||
|
||||
|
||||
diff --git a/pom.xml b/pom.xml
|
||||
index 6857042b3475925f426cbe9f4858438a02bebd23..a295e88e8c05306c0e5876608797d64df6dc1699 100644
|
||||
--- a/pom.xml
|
||||
+++ b/pom.xml
|
||||
@@ -19,8 +19,10 @@
|
||||
|
||||
<properties>
|
||||
<!-- <skipTests>true</skipTests> Paper - This [was] not going to end well -->
|
||||
- <maven.compiler.source>1.8</maven.compiler.source>
|
||||
- <maven.compiler.target>1.8</maven.compiler.target>
|
||||
+ <!-- Parchment start -->
|
||||
+ <maven.compiler.source>15</maven.compiler.source>
|
||||
+ <maven.compiler.target>15</maven.compiler.target>
|
||||
+ <!-- Parchment end -->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<adventure.version>4.7.0</adventure.version> <!-- Paper - When updating this make sure to update the linked JavaDocs on the homepage as well! -->
|
||||
</properties>
|
||||
@@ -148,7 +150,7 @@
|
||||
<!-- annotations -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
- <artifactId>annotations-java5</artifactId>
|
||||
+ <artifactId>annotations</artifactId> <!-- Parchment -->
|
||||
<version>20.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
@@ -278,15 +280,38 @@
|
||||
</properties>
|
||||
</configuration>
|
||||
</plugin>
|
||||
+ <!-- Parchment start -->
|
||||
+ <plugin>
|
||||
+ <groupId>org.apache.maven.plugins</groupId>
|
||||
+ <artifactId>maven-source-plugin</artifactId>
|
||||
+ <version>3.2.0</version>
|
||||
+ <executions>
|
||||
+ <execution>
|
||||
+ <id>attach-sources</id>
|
||||
+ <goals>
|
||||
+ <goal>jar</goal>
|
||||
+ </goals>
|
||||
+ </execution>
|
||||
+ </executions>
|
||||
+ </plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
+ <executions>
|
||||
+ <execution>
|
||||
+ <id>attach-javadocs</id>
|
||||
+ <goals>
|
||||
+ <goal>jar</goal>
|
||||
+ </goals>
|
||||
+ </execution>
|
||||
+ </executions>
|
||||
<configuration>
|
||||
+ <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
|
||||
<links>
|
||||
<link>https://guava.dev/releases/21.0/api/docs/</link>
|
||||
<link>https://javadoc.io/doc/org.yaml/snakeyaml/1.27/</link>
|
||||
- <link>https://javadoc.io/doc/org.jetbrains/annotations-java5/20.1.0/</link>
|
||||
+ <link>https://javadoc.io/doc/org.jetbrains/annotations/20.1.0/</link> <!-- Parchment -->
|
||||
<link>https://javadoc.io/doc/net.md-5/bungeecord-chat/1.16-R0.4/</link>
|
||||
<!-- Paper start -->
|
||||
<link>https://jd.adventure.kyori.net/api/${adventure.version}/</link>
|
||||
@@ -297,6 +322,7 @@
|
||||
</links>
|
||||
</configuration>
|
||||
</plugin>
|
||||
+ <!-- Parchment end -->
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: lexikiq <noellekiq@gmail.com>
|
||||
Date: Mon, 10 May 2021 22:10:23 -0400
|
||||
Subject: [PATCH] Add origin location to EntityDamageByBlockEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java
|
||||
index 461727dc7f06efb3550fc370e0db5bd04ba89711..cd3ad8ce0f3f22f1292ae81e3a974d0d464a388c 100644
|
||||
--- a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java
|
||||
@@ -12,17 +12,38 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public class EntityDamageByBlockEvent extends EntityDamageEvent {
|
||||
private final Block damager;
|
||||
+ private final org.bukkit.Location location; // Parchment
|
||||
|
||||
public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) {
|
||||
super(damagee, cause, damage);
|
||||
this.damager = damager;
|
||||
+ this.location = damager != null ? damager.getLocation() : null; // Parchment
|
||||
}
|
||||
|
||||
public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
|
||||
super(damagee, cause, modifiers, modifierFunctions);
|
||||
this.damager = damager;
|
||||
+ this.location = damager != null ? damager.getLocation() : null; // Parchment
|
||||
}
|
||||
|
||||
+ // Parchment start
|
||||
+ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @Nullable final org.bukkit.Location damageLocation, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
|
||||
+ super(damagee, cause, modifiers, modifierFunctions);
|
||||
+ this.damager = damager;
|
||||
+ this.location = damageLocation;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the location of the damage source.
|
||||
+ *
|
||||
+ * @return Originating location of the damage source
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public org.bukkit.Location getLocation() {
|
||||
+ return location;
|
||||
+ }
|
||||
+ // Parchment end
|
||||
+
|
||||
/**
|
||||
* Returns the block that damaged the player.
|
||||
*
|
||||
@@ -1,114 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: lexikiq <noellekiq@gmail.com>
|
||||
Date: Thu, 13 May 2021 23:55:02 -0400
|
||||
Subject: [PATCH] Create PlayerUseRespawnAnchorEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/lexikiq/event/player/PlayerUseRespawnAnchorEvent.java b/src/main/java/me/lexikiq/event/player/PlayerUseRespawnAnchorEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..96b552fe0bd6e6507c1c4f9380cab32e725cb129
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/lexikiq/event/player/PlayerUseRespawnAnchorEvent.java
|
||||
@@ -0,0 +1,102 @@
|
||||
+package me.lexikiq.event.player;
|
||||
+
|
||||
+import org.bukkit.block.Block;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.player.PlayerEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * This event is fired immediately before the result of using a respawn anchor is executed
|
||||
+ */
|
||||
+public class PlayerUseRespawnAnchorEvent extends PlayerEvent implements Cancellable {
|
||||
+
|
||||
+ /**
|
||||
+ * Represents the default possible outcomes of this event.
|
||||
+ */
|
||||
+ public enum RespawnAnchorResult {
|
||||
+ /**
|
||||
+ * The player's spawn point will be set
|
||||
+ */
|
||||
+ SET_SPAWN,
|
||||
+ /**
|
||||
+ * The respawn anchor will explode due to being used outside the nether
|
||||
+ */
|
||||
+ EXPLODE,
|
||||
+ /**
|
||||
+ * The player will charge the respawn anchor
|
||||
+ */
|
||||
+ CHARGE
|
||||
+ }
|
||||
+
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final Block respawnAnchor;
|
||||
+ private final RespawnAnchorResult respawnAnchorResult;
|
||||
+ private boolean cancelled = false;
|
||||
+
|
||||
+ public PlayerUseRespawnAnchorEvent(@NotNull Player who, @NotNull Block respawnAnchor, @NotNull RespawnAnchorResult respawnAnchorResult) {
|
||||
+ super(who);
|
||||
+ this.respawnAnchor = respawnAnchor;
|
||||
+ this.respawnAnchorResult = respawnAnchorResult;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the respawn anchor block involved in this event.
|
||||
+ *
|
||||
+ * @return the respawn anchor block involved in this event
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Block getRespawnAnchor() {
|
||||
+ return this.respawnAnchor;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Describes the outcome of the event.
|
||||
+ *
|
||||
+ * @return the respawn anchor result for the outcome of the event
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public RespawnAnchorResult getRespawnAnchorResult() {
|
||||
+ return this.respawnAnchorResult;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the cancellation state of this event. A cancelled event will not
|
||||
+ * be executed in the server, but will still pass to other plugins.
|
||||
+ * <p>
|
||||
+ * A positive value means the respawn anchor will not take any action, as
|
||||
+ * if it had not been clicked at all.
|
||||
+ *
|
||||
+ * @return true if this event is cancelled
|
||||
+ */
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the cancellation state of this event. A canceled event will not be
|
||||
+ * executed in the server, but will still pass to other plugins.
|
||||
+ * <p>
|
||||
+ * Canceling this event will prevent use of the respawn anchor, leaving it
|
||||
+ * as thought it hadn't been clicked at all.
|
||||
+ *
|
||||
+ * @param cancel true if you wish to cancel this event
|
||||
+ */
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
@@ -1,308 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: lexikiq <noellekiq@gmail.com>
|
||||
Date: Fri, 14 May 2021 21:05:49 -0400
|
||||
Subject: [PATCH] Make OptionalPlayerLike extend Audience
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/lexikiq/OptionalPlayer.java b/src/main/java/me/lexikiq/OptionalPlayer.java
|
||||
index 70fcce84e8b42f3a2c3543b8365b25cc90addc8d..428e25fa82e276c473f3d96e56ac1539431a6674 100644
|
||||
--- a/src/main/java/me/lexikiq/OptionalPlayer.java
|
||||
+++ b/src/main/java/me/lexikiq/OptionalPlayer.java
|
||||
@@ -13,4 +13,13 @@ public interface OptionalPlayer extends OptionalHumanEntity {
|
||||
* @return player or null
|
||||
*/
|
||||
@Nullable Player getPlayer();
|
||||
+
|
||||
+ /**
|
||||
+ * Tests if the {@link Player} represented by this object is online.
|
||||
+ *
|
||||
+ * @return true if online
|
||||
+ */
|
||||
+ default boolean isOnline() {
|
||||
+ return getPlayer() != null;
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/me/lexikiq/OptionalPlayerLike.java b/src/main/java/me/lexikiq/OptionalPlayerLike.java
|
||||
index aaa1879f9560ef6ff415e98a5fdf2403f0480a0b..d56c4612ac601fb43a277ee3102726e6547cfee8 100644
|
||||
--- a/src/main/java/me/lexikiq/OptionalPlayerLike.java
|
||||
+++ b/src/main/java/me/lexikiq/OptionalPlayerLike.java
|
||||
@@ -1,16 +1,200 @@
|
||||
package me.lexikiq;
|
||||
|
||||
+import net.kyori.adventure.audience.Audience;
|
||||
+import net.kyori.adventure.audience.MessageType;
|
||||
+import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.identity.Identified;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
-import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import net.kyori.adventure.inventory.Book;
|
||||
+import net.kyori.adventure.sound.Sound;
|
||||
+import net.kyori.adventure.sound.SoundStop;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.title.Title;
|
||||
+import org.apache.commons.lang.Validate;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Class that may be like a {@link org.bukkit.entity.Player} in that it has a {@link java.util.UUID}, {@link org.bukkit.OfflinePlayer}, {@link Identity}, and a nullable Player.
|
||||
+ * <p>
|
||||
+ * This class extends the {@link Audience} interface and will silently fail if the player is not online.
|
||||
* @see me.lexikiq.PlayerLike
|
||||
*/
|
||||
-public interface OptionalPlayerLike extends OptionalPlayer, HasUniqueId, HasOfflinePlayer, Identified {
|
||||
+public interface OptionalPlayerLike extends OptionalPlayer, HasUniqueId, HasOfflinePlayer, Identified, Audience {
|
||||
+ /**
|
||||
+ * Gets the identity corresponding with this object.
|
||||
+ *
|
||||
+ * @return the identity
|
||||
+ * @since 4.0.0
|
||||
+ */
|
||||
@Override
|
||||
- default @NonNull Identity identity() {
|
||||
+ default @NotNull Identity identity() {
|
||||
return Identity.identity(getUniqueId());
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Run a consumer with the {@link Player} associated with this object if the player is online.
|
||||
+ * <p>
|
||||
+ * Allows easily running a code on the player only if they are connected.
|
||||
+ *
|
||||
+ * @param consumer function that accepts a Player
|
||||
+ */
|
||||
+ default void consumeIfOnline(final @NotNull Consumer<@NotNull Player> consumer) {
|
||||
+ Validate.notNull(consumer, "Consumer<Player> should not be null");
|
||||
+
|
||||
+ final Player player = getPlayer();
|
||||
+ if (player != null)
|
||||
+ consumer.accept(player);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sends a chat message.
|
||||
+ *
|
||||
+ * @param source the identity of the source of the message
|
||||
+ * @param message a message
|
||||
+ * @param type the type
|
||||
+ * @see Component
|
||||
+ * @since 4.0.0
|
||||
+ */
|
||||
+ @Override
|
||||
+ default void sendMessage(final @NotNull Identity source, final @NotNull Component message, final @NotNull MessageType type) {
|
||||
+ consumeIfOnline(player -> player.sendMessage(source, message, type));
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sends a message on the action bar.
|
||||
+ *
|
||||
+ * @param message a message
|
||||
+ * @see Component
|
||||
+ * @since 4.0.0
|
||||
+ */
|
||||
+ @Override
|
||||
+ default void sendActionBar(final @NotNull Component message) {
|
||||
+ consumeIfOnline(player -> player.sendActionBar(message));
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sends the player list header and footer.
|
||||
+ *
|
||||
+ * @param header the header
|
||||
+ * @param footer the footer
|
||||
+ * @since 4.3.0
|
||||
+ */
|
||||
+ @Override
|
||||
+ default void sendPlayerListHeaderAndFooter(final @NotNull Component header, final @NotNull Component footer) {
|
||||
+ consumeIfOnline(player -> player.sendPlayerListHeaderAndFooter(header, footer));
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Shows a title.
|
||||
+ *
|
||||
+ * @param title a title
|
||||
+ * @see Title
|
||||
+ * @since 4.0.0
|
||||
+ */
|
||||
+ @Override
|
||||
+ default void showTitle(final @NotNull Title title) {
|
||||
+ consumeIfOnline(player -> player.showTitle(title));
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Clears the title, if one is being displayed.
|
||||
+ *
|
||||
+ * @see Title
|
||||
+ * @since 4.0.0
|
||||
+ */
|
||||
+ @Override
|
||||
+ default void clearTitle() {
|
||||
+ consumeIfOnline(Audience::clearTitle);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Resets the title and timings back to their default.
|
||||
+ *
|
||||
+ * @see Title
|
||||
+ * @since 4.0.0
|
||||
+ */
|
||||
+ @Override
|
||||
+ default void resetTitle() {
|
||||
+ consumeIfOnline(Audience::resetTitle);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Shows a boss bar.
|
||||
+ *
|
||||
+ * @param bar a boss bar
|
||||
+ * @see BossBar
|
||||
+ * @since 4.0.0
|
||||
+ */
|
||||
+ @Override
|
||||
+ default void showBossBar(final @NotNull BossBar bar) {
|
||||
+ consumeIfOnline(player -> player.showBossBar(bar));
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Hides a boss bar.
|
||||
+ *
|
||||
+ * @param bar a boss bar
|
||||
+ * @see BossBar
|
||||
+ * @since 4.0.0
|
||||
+ */
|
||||
+ @Override
|
||||
+ default void hideBossBar(final @NotNull BossBar bar) {
|
||||
+ consumeIfOnline(player -> player.hideBossBar(bar));
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Plays a sound.
|
||||
+ *
|
||||
+ * @param sound a sound
|
||||
+ * @see Sound
|
||||
+ * @since 4.0.0
|
||||
+ */
|
||||
+ @Override
|
||||
+ default void playSound(final @NotNull Sound sound) {
|
||||
+ consumeIfOnline(player -> player.playSound(sound));
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Plays a sound at a location.
|
||||
+ *
|
||||
+ * @param sound a sound
|
||||
+ * @param x x coordinate
|
||||
+ * @param y y coordinate
|
||||
+ * @param z z coordinate
|
||||
+ * @see Sound
|
||||
+ * @since 4.0.0
|
||||
+ */
|
||||
+ @Override
|
||||
+ default void playSound(final @NotNull Sound sound, final double x, final double y, final double z) {
|
||||
+ consumeIfOnline(player -> player.playSound(sound, x, y, z));
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Stops a sound, or many sounds.
|
||||
+ *
|
||||
+ * @param stop a sound stop
|
||||
+ * @see SoundStop
|
||||
+ * @since 4.0.0
|
||||
+ */
|
||||
+ @Override
|
||||
+ default void stopSound(final @NotNull SoundStop stop) {
|
||||
+ consumeIfOnline(player -> player.stopSound(stop));
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Opens a book.
|
||||
+ *
|
||||
+ * <p>When possible, no item should persist after closing the book.</p>
|
||||
+ *
|
||||
+ * @param book a book
|
||||
+ * @see Book
|
||||
+ * @since 4.0.0
|
||||
+ */
|
||||
+ @Override
|
||||
+ default void openBook(final @NotNull Book book) {
|
||||
+ consumeIfOnline(player -> player.openBook(book));
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/me/lexikiq/PlayerLike.java b/src/main/java/me/lexikiq/PlayerLike.java
|
||||
index 3184f585f9c6e59ce9297d6613749453ce5e6ab5..d00a256c3a489d918c4d9bef1023e621d0faece3 100644
|
||||
--- a/src/main/java/me/lexikiq/PlayerLike.java
|
||||
+++ b/src/main/java/me/lexikiq/PlayerLike.java
|
||||
@@ -1,7 +1,24 @@
|
||||
package me.lexikiq;
|
||||
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.function.Consumer;
|
||||
+
|
||||
/**
|
||||
* Class that is like a {@link org.bukkit.entity.Player} in that it has a Player, {@link java.util.UUID}, {@link org.bukkit.OfflinePlayer}, and an {@link net.kyori.adventure.identity.Identity}.
|
||||
* @see me.lexikiq.OptionalPlayerLike
|
||||
*/
|
||||
-public interface PlayerLike extends HasPlayer, OptionalPlayerLike {}
|
||||
+public interface PlayerLike extends HasPlayer, OptionalPlayerLike {
|
||||
+
|
||||
+ /**
|
||||
+ * Run a consumer with the {@link Player} associated with this object.
|
||||
+ * Unlike the parent class {@link OptionalPlayerLike}, this will always run.
|
||||
+ *
|
||||
+ * @param consumer function that accepts a Player
|
||||
+ */
|
||||
+ @Override
|
||||
+ default void consumeIfOnline(@NotNull Consumer<@NotNull Player> consumer) {
|
||||
+ consumer.accept(getPlayer());
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/OfflinePlayer.java b/src/main/java/org/bukkit/OfflinePlayer.java
|
||||
index 95220ef8ad0602fae9f88c0231762ff50358d98f..27e837a0dbcf37fff9927deb1c34a3ca96a7a49f 100644
|
||||
--- a/src/main/java/org/bukkit/OfflinePlayer.java
|
||||
+++ b/src/main/java/org/bukkit/OfflinePlayer.java
|
||||
@@ -3,9 +3,7 @@ package org.bukkit;
|
||||
import java.util.UUID;
|
||||
|
||||
import me.lexikiq.HasOfflinePlayer;
|
||||
-import me.lexikiq.HasUniqueId;
|
||||
import me.lexikiq.OptionalPlayer;
|
||||
-import me.lexikiq.OptionalPlayerLike;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -14,7 +12,7 @@ import org.bukkit.permissions.ServerOperator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
-public interface OfflinePlayer extends ServerOperator, AnimalTamer, ConfigurationSerializable, OptionalPlayerLike { // Parchment
|
||||
+public interface OfflinePlayer extends ServerOperator, AnimalTamer, ConfigurationSerializable, HasOfflinePlayer, OptionalPlayer { // Parchment
|
||||
// Parchment start
|
||||
@Override
|
||||
@NotNull default OfflinePlayer getOfflinePlayer() {
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 2c9aa0cbce1450695b285a9e654b0e9f10e28c37..b7ce4b50a7f8f9488cb30a40f0e8acaf2b8d33e7 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -5,8 +5,8 @@ import java.util.Set; // Paper
|
||||
import java.util.UUID;
|
||||
import com.destroystokyo.paper.ClientOption; // Paper
|
||||
import com.destroystokyo.paper.Title; // Paper
|
||||
+import me.lexikiq.HasOfflinePlayer;
|
||||
import me.lexikiq.HasPlayer;
|
||||
-import me.lexikiq.PlayerLike;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import com.destroystokyo.paper.profile.PlayerProfile; // Paper
|
||||
import java.util.Date; // Paper
|
||||
@@ -41,7 +41,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* Represents a player, connected or not
|
||||
*/
|
||||
-public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, com.destroystokyo.paper.network.NetworkClient, PlayerLike { // Paper // Parchment
|
||||
+public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, com.destroystokyo.paper.network.NetworkClient, HasOfflinePlayer, HasPlayer { // Paper // Parchment
|
||||
|
||||
// Parchment start
|
||||
/**
|
||||
@@ -1,360 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: lexikiq <noellekiq@gmail.com>
|
||||
Date: Tue, 1 Jun 2021 16:22:54 -0400
|
||||
Subject: [PATCH] Add SoundEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/lexikiq/event/sound/EntitySoundEvent.java b/src/main/java/me/lexikiq/event/sound/EntitySoundEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..bf7cd3b9183925cdeef2969cad045bf766a54742
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/lexikiq/event/sound/EntitySoundEvent.java
|
||||
@@ -0,0 +1,44 @@
|
||||
+package me.lexikiq.event.sound;
|
||||
+
|
||||
+import org.apache.commons.lang.Validate;
|
||||
+import org.bukkit.Sound;
|
||||
+import org.bukkit.SoundCategory;
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Called when an entity sound is sent to a player. Cancelling this event will prevent the packet from sending.
|
||||
+ * <p>
|
||||
+ * This type of sound represents one that will follow the {@link #origin} entity.
|
||||
+ */
|
||||
+public class EntitySoundEvent extends NamedSoundEvent {
|
||||
+ private @NotNull Entity origin;
|
||||
+
|
||||
+ public EntitySoundEvent(@Nullable HumanEntity receiver, @NotNull Entity origin, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) {
|
||||
+ super(receiver, sound, category, volume, pitch);
|
||||
+ Validate.notNull(origin, "origin cannot be null");
|
||||
+ this.origin = origin;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the entity that the sound is originating from
|
||||
+ * @return originating entity
|
||||
+ */
|
||||
+ public @NotNull Entity getOrigin() {
|
||||
+ return origin;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the entity that the sound will originate from
|
||||
+ * @param origin originating entity
|
||||
+ */
|
||||
+ public void setOrigin(@NotNull Entity origin) {
|
||||
+ Validate.notNull(origin, "origin cannot be null");
|
||||
+ if (!this.origin.getWorld().equals(origin.getWorld()))
|
||||
+ throw new IllegalArgumentException("Entity must be in same world as originating location");
|
||||
+ this.origin = origin;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/me/lexikiq/event/sound/LocationCustomSoundEvent.java b/src/main/java/me/lexikiq/event/sound/LocationCustomSoundEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8ce556953dd175336ef887c508ad8e027b9df4a6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/lexikiq/event/sound/LocationCustomSoundEvent.java
|
||||
@@ -0,0 +1,73 @@
|
||||
+package me.lexikiq.event.sound;
|
||||
+
|
||||
+import org.apache.commons.lang.Validate;
|
||||
+import org.bukkit.Keyed;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.SoundCategory;
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+import org.bukkit.util.Vector;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a sound not available in {@link org.bukkit.Sound} is sent to a player from a {@link Location}. Cancelling this event will prevent the packet from sending.
|
||||
+ */
|
||||
+public class LocationCustomSoundEvent extends SoundEvent implements Keyed {
|
||||
+ private @NotNull Vector vector;
|
||||
+ private @NotNull NamespacedKey key;
|
||||
+ private @NotNull final World world;
|
||||
+
|
||||
+ public LocationCustomSoundEvent(@Nullable HumanEntity receiver, @NotNull World world, @NotNull Vector vector, @NotNull NamespacedKey key, @NotNull SoundCategory category, float volume, float pitch) {
|
||||
+ super(receiver, category, volume, pitch);
|
||||
+ Validate.notNull(world, "world cannot be null");
|
||||
+ Validate.notNull(vector, "vector cannot be null");
|
||||
+ Validate.notNull(key, "key cannot be null");
|
||||
+ this.world = world;
|
||||
+ this.vector = vector;
|
||||
+ this.key = key;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the position in the world of the sound
|
||||
+ * @return position in the world
|
||||
+ */
|
||||
+ public @NotNull Vector getVector() {
|
||||
+ return vector;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the resource pack key of the sound
|
||||
+ * @return asset key
|
||||
+ */
|
||||
+ public @NotNull NamespacedKey getKey() {
|
||||
+ return key;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the world in which the sound is being played
|
||||
+ * @return sound's world
|
||||
+ */
|
||||
+ public @NotNull World getWorld() {
|
||||
+ return world;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the position in the world of the sound
|
||||
+ * @param vector position in the world
|
||||
+ */
|
||||
+ public void setVector(@NotNull Vector vector) {
|
||||
+ Validate.notNull(vector, "vector cannot be null");
|
||||
+ this.vector = vector;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the resource pack key of the sound
|
||||
+ * @param key asset key
|
||||
+ */
|
||||
+ public void setKey(@NotNull NamespacedKey key) {
|
||||
+ Validate.notNull(key, "key cannot be null");
|
||||
+ this.key = key;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/lexikiq/event/sound/LocationNamedSoundEvent.java b/src/main/java/me/lexikiq/event/sound/LocationNamedSoundEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..242a7f3d4d6ab6ff7000e544605a69eac35f03a8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/lexikiq/event/sound/LocationNamedSoundEvent.java
|
||||
@@ -0,0 +1,52 @@
|
||||
+package me.lexikiq.event.sound;
|
||||
+
|
||||
+import org.apache.commons.lang.Validate;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.Sound;
|
||||
+import org.bukkit.SoundCategory;
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+import org.bukkit.util.Vector;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a sound available in {@link Sound} is sent to a player from a {@link Location}. Cancelling this event will prevent the packet from sending.
|
||||
+ */
|
||||
+public class LocationNamedSoundEvent extends NamedSoundEvent {
|
||||
+ private @NotNull Vector vector;
|
||||
+ private @NotNull final World world;
|
||||
+
|
||||
+ public LocationNamedSoundEvent(@Nullable HumanEntity receiver, @NotNull World world, @NotNull Vector vector, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) {
|
||||
+ super(receiver, sound, category, volume, pitch);
|
||||
+ Validate.notNull(world, "world cannot be null");
|
||||
+ Validate.notNull(vector, "vector cannot be null");
|
||||
+ this.world = world;
|
||||
+ this.vector = vector;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the position in the world of the sound
|
||||
+ * @return position in the world
|
||||
+ */
|
||||
+ public @NotNull Vector getVector() {
|
||||
+ return vector;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the world in which the sound is being played
|
||||
+ * @return sound's world
|
||||
+ */
|
||||
+ public @NotNull World getWorld() {
|
||||
+ return world;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the position in the world of the sound
|
||||
+ * @param vector position in the world
|
||||
+ */
|
||||
+ public void setVector(@NotNull Vector vector) {
|
||||
+ Validate.notNull(vector, "vector cannot be null");
|
||||
+ this.vector = vector;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/lexikiq/event/sound/NamedSoundEvent.java b/src/main/java/me/lexikiq/event/sound/NamedSoundEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..516352ffb64fd025be018f5389a7c80e62743c9a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/lexikiq/event/sound/NamedSoundEvent.java
|
||||
@@ -0,0 +1,40 @@
|
||||
+package me.lexikiq.event.sound;
|
||||
+
|
||||
+import org.apache.commons.lang.Validate;
|
||||
+import org.bukkit.Sound;
|
||||
+import org.bukkit.SoundCategory;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a sound available in {@link Sound} is sent to a player. Cancelling this event will prevent the packet from sending.
|
||||
+ * <p>
|
||||
+ * Note: this does not directly correspond to any given sound packet. It is provided for listening convenience.
|
||||
+ */
|
||||
+public class NamedSoundEvent extends SoundEvent {
|
||||
+ private @NotNull Sound sound;
|
||||
+
|
||||
+ public NamedSoundEvent(@Nullable HumanEntity receiver, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) {
|
||||
+ super(receiver, category, volume, pitch);
|
||||
+ Validate.notNull(sound, "sound cannot be null");
|
||||
+ this.sound = sound;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the sound being played
|
||||
+ * @return sound to play
|
||||
+ */
|
||||
+ public @NotNull Sound getSound() {
|
||||
+ return sound;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the sound yo played
|
||||
+ * @param sound sound to play
|
||||
+ */
|
||||
+ public void setSound(@NotNull Sound sound) {
|
||||
+ Validate.notNull(sound, "sound cannot be null");
|
||||
+ this.sound = sound;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/lexikiq/event/sound/SoundEvent.java b/src/main/java/me/lexikiq/event/sound/SoundEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..05cd0148bec4770ce78fceda1fe57cf625b0bacf
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/lexikiq/event/sound/SoundEvent.java
|
||||
@@ -0,0 +1,115 @@
|
||||
+package me.lexikiq.event.sound;
|
||||
+
|
||||
+import me.lexikiq.OptionalHumanEntity;
|
||||
+import org.apache.commons.lang.Validate;
|
||||
+import org.bukkit.SoundCategory;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a sound is sent to a player. Cancelling this event will prevent the packet from sending.
|
||||
+ * <p>
|
||||
+ * Note: this does not directly correspond to any given sound packet. It is provided for listening convenience.
|
||||
+ */
|
||||
+public class SoundEvent extends Event implements Cancellable, OptionalHumanEntity {
|
||||
+ private @Nullable final HumanEntity receiver;
|
||||
+ private @NotNull SoundCategory category;
|
||||
+ private float volume;
|
||||
+ private float pitch;
|
||||
+ private boolean cancelled;
|
||||
+
|
||||
+ public SoundEvent(@Nullable HumanEntity receiver, @NotNull SoundCategory category, float volume, float pitch) {
|
||||
+ super(true);
|
||||
+ Validate.notNull(category, "category cannot be null");
|
||||
+ this.receiver = receiver;
|
||||
+ this.category = category;
|
||||
+ this.volume = volume;
|
||||
+ this.pitch = pitch;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the player that this sound will be sent to. May be null if the sound is being played to several players.
|
||||
+ * @return player receiving the sound
|
||||
+ */
|
||||
+ @Override
|
||||
+ public @Nullable HumanEntity getPlayer() {
|
||||
+ return receiver;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the category of sounds this will be played with.
|
||||
+ * @return category of sounds
|
||||
+ */
|
||||
+ public @NotNull SoundCategory getCategory() {
|
||||
+ return category;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the volume of the sound to be played. Should be non-negative.
|
||||
+ * @return sound volume
|
||||
+ */
|
||||
+ public float getVolume() {
|
||||
+ return volume;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the pitch of the sound to be played. Should be within the range [0,2].
|
||||
+ * @return sound pitch
|
||||
+ */
|
||||
+ public float getPitch() {
|
||||
+ return pitch;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the category of sounds this will be played with.
|
||||
+ * @param category category of sounds
|
||||
+ */
|
||||
+ public void setCategory(@NotNull SoundCategory category) {
|
||||
+ Validate.notNull(category, "category cannot be null");
|
||||
+ this.category = category;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the volume of the sound to be played. Must be non-negative.
|
||||
+ * @param volume sound volume
|
||||
+ */
|
||||
+ public void setVolume(float volume) {
|
||||
+ Validate.isTrue(volume >= 0, "volume should be non-negative");
|
||||
+ this.volume = volume;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the pitch of the sound to be played. Must be within the range [0,2].
|
||||
+ * @param pitch sound pitch
|
||||
+ */
|
||||
+ public void setPitch(float pitch) {
|
||||
+ Validate.isTrue(pitch >= 0 && pitch <= 2, "pitch should be within range [0,2]");
|
||||
+ this.pitch = pitch;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancelled) {
|
||||
+ this.cancelled = cancelled;
|
||||
+ }
|
||||
+
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
Reference in New Issue
Block a user