diff --git a/pom.xml b/pom.xml index 677f8348..4454fd24 100644 --- a/pom.xml +++ b/pom.xml @@ -90,6 +90,11 @@ spigot 1.15-R0.1-SNAPSHOT + + org.spigotmc + spigot + 1.15-R0.1-SNAPSHOT + junit @@ -97,6 +102,12 @@ 4.12 test + + com.destroystokyo.paper + paper-api + 1.15.2-R0.1-SNAPSHOT + provided + @@ -112,6 +123,10 @@ spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + papermc + https://papermc.io/repo/repository/maven-public/ + diff --git a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java index 44592b98..4a7f1b3c 100644 --- a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java @@ -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()) { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/listeners/PaperDisguiseListener.java b/src/main/java/me/libraryaddict/disguise/utilities/listeners/PaperDisguiseListener.java new file mode 100644 index 00000000..40b899f3 --- /dev/null +++ b/src/main/java/me/libraryaddict/disguise/utilities/listeners/PaperDisguiseListener.java @@ -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(); + } + } +}