Add paper specific listener for entity loading

This commit is contained in:
libraryaddict 2020-05-20 12:43:27 +12:00
parent 43015f192f
commit fcd93ec704
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4
3 changed files with 54 additions and 0 deletions

15
pom.xml
View File

@ -90,6 +90,11 @@
<artifactId>spigot</artifactId>
<version>1.15-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15-R0.1-SNAPSHOT</version>
</dependency>
<!-- testing -->
<dependency>
<groupId>junit</groupId>
@ -97,6 +102,12 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
@ -112,6 +123,10 @@
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
</repositories>
<distributionManagement>

View File

@ -18,6 +18,7 @@ import me.libraryaddict.disguise.commands.utils.*;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.listeners.DisguiseListener;
import me.libraryaddict.disguise.utilities.listeners.PaperDisguiseListener;
import me.libraryaddict.disguise.utilities.metrics.MetricsInitalizer;
import me.libraryaddict.disguise.utilities.packets.PacketsManager;
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
@ -132,6 +133,10 @@ public class LibsDisguises extends JavaPlugin {
listener = new DisguiseListener(this);
if (DisguiseUtilities.isRunningPaper()) {
Bukkit.getPluginManager().registerEvents(new PaperDisguiseListener(), this);
}
registerCommand("libsdisguises", new LibsDisguisesCommand());
if (!DisguiseConfig.isDisableCommands()) {

View File

@ -0,0 +1,34 @@
package me.libraryaddict.disguise.utilities.listeners;
import com.destroystokyo.paper.event.entity.EntityAddToWorldEvent;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
* Created by libraryaddict on 20/05/2020.
*/
public class PaperDisguiseListener implements Listener {
@EventHandler
public void onEntityLoad(EntityAddToWorldEvent event) {
if (!DisguiseConfig.isSaveEntityDisguises())
return;
Entity entity = event.getEntity();
Disguise[] disguises = DisguiseUtilities.getSavedDisguises(entity.getUniqueId(), true);
if (disguises.length <= 0)
return;
DisguiseUtilities.resetPluginTimer();
for (Disguise disguise : disguises) {
disguise.setEntity(entity);
disguise.startDisguise();
}
}
}