mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-12 15:07:22 +01:00
Add paper specific listener for entity loading
This commit is contained in:
parent
43015f192f
commit
fcd93ec704
15
pom.xml
15
pom.xml
@ -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>
|
||||
|
@ -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()) {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user