From bc14c39d687b793ef8180aee2a23cbd0c59a126f Mon Sep 17 00:00:00 2001 From: carm Date: Tue, 14 Feb 2023 23:06:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(effect):=20=E6=94=AF=E6=8C=81=E7=AE=80?= =?UTF-8?q?=E5=8D=95=E7=9A=84=E4=BC=A0=E9=80=81=E7=B2=92=E5=AD=90=E6=95=88?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 11 +++++++++++ .../java/cc/carm/plugin/moeteleport/Main.java | 13 ++++++++++--- .../moeteleport/listener/TeleportListener.java | 2 +- .../moeteleport/manager/TeleportManager.java | 18 ++++++++++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 6032c06..244b648 100644 --- a/pom.xml +++ b/pom.xml @@ -175,6 +175,13 @@ true + + xyz.xenondevs + particle + 1.8.3 + compile + true + org.spigotmc @@ -313,6 +320,10 @@ org.bstats cc.carm.plugin.moeteleport.lib.bstats + + xyz.xenondevs.particle + cc.carm.plugin.moeteleport.lib.praticle + org.json cc.carm.plugin.moeteleport.lib.json diff --git a/src/main/java/cc/carm/plugin/moeteleport/Main.java b/src/main/java/cc/carm/plugin/moeteleport/Main.java index c4a8156..735cfb7 100644 --- a/src/main/java/cc/carm/plugin/moeteleport/Main.java +++ b/src/main/java/cc/carm/plugin/moeteleport/Main.java @@ -15,6 +15,7 @@ import cc.carm.plugin.moeteleport.storage.StorageMethod; import org.bstats.bukkit.Metrics; import org.bstats.charts.SimplePie; import org.bukkit.Bukkit; +import xyz.xenondevs.particle.utils.ReflectionUtils; public class Main extends EasyPlugin { private static Main instance; @@ -34,7 +35,7 @@ public class Main extends EasyPlugin { } @Override - protected boolean initialize() { + protected void load() { log("加载插件配置文件..."); this.configProvider = MineConfiguration.from(this, "config.yml"); @@ -43,6 +44,11 @@ public class Main extends EasyPlugin { this.messageProvider = MineConfiguration.from(this, "messages.yml"); this.messageProvider.initialize(PluginMessages.class); + } + + @Override + protected boolean initialize() { + log("初始化存储方式..."); StorageMethod storageMethod = StorageMethod.read(PluginConfig.STORAGE.METHOD.get()); @@ -56,7 +62,6 @@ public class Main extends EasyPlugin { return false; // 初始化失败,不再继续加载 } - log("加载地标管理器..."); warpManager = new WarpManager(); @@ -90,7 +95,6 @@ public class Main extends EasyPlugin { e.printStackTrace(); } - if (PluginConfig.METRICS.getNotNull()) { log("启用统计数据..."); Metrics metrics = new Metrics(this, 14459); @@ -104,6 +108,9 @@ public class Main extends EasyPlugin { log("已禁用检查更新,跳过。"); } + log("初始化粒子库..."); + ReflectionUtils.setPlugin(this); + return true; } diff --git a/src/main/java/cc/carm/plugin/moeteleport/listener/TeleportListener.java b/src/main/java/cc/carm/plugin/moeteleport/listener/TeleportListener.java index a114b94..87bac78 100644 --- a/src/main/java/cc/carm/plugin/moeteleport/listener/TeleportListener.java +++ b/src/main/java/cc/carm/plugin/moeteleport/listener/TeleportListener.java @@ -23,7 +23,7 @@ public class TeleportListener implements Listener { if (from.getBlockX() == to.getBlockX() && from.getBlockY() == to.getBlockY() - && from.getBlockZ() == to.getBlockZ()){ + && from.getBlockZ() == to.getBlockZ()) { return; } diff --git a/src/main/java/cc/carm/plugin/moeteleport/manager/TeleportManager.java b/src/main/java/cc/carm/plugin/moeteleport/manager/TeleportManager.java index a20d093..193858c 100644 --- a/src/main/java/cc/carm/plugin/moeteleport/manager/TeleportManager.java +++ b/src/main/java/cc/carm/plugin/moeteleport/manager/TeleportManager.java @@ -12,6 +12,8 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.Nullable; +import xyz.xenondevs.particle.ParticleBuilder; +import xyz.xenondevs.particle.ParticleEffect; import java.time.Duration; import java.time.temporal.ChronoUnit; @@ -42,6 +44,8 @@ public class TeleportManager { } public void tickQueue() { + boolean enableEffect = PluginConfig.TELEPORTATION.EFFECTS.getNotNull(); + Iterator> queueIterator = teleportQueue.entrySet().iterator(); while (queueIterator.hasNext()) { Map.Entry entry = queueIterator.next(); @@ -52,6 +56,12 @@ public class TeleportManager { queue.getPlayer(), queue.getRemainSeconds() + 1, queue.getTarget().getText() ); + + if (enableEffect) { + new ParticleBuilder(ParticleEffect.PORTAL, queue.getPlayer().getLocation()) + .setAmount(100).display(); + } + continue; } @@ -74,6 +84,14 @@ public class TeleportManager { return getQueue(player.getUniqueId()); } + public boolean isChanneling(UUID uuid) { + return teleportQueue.containsKey(uuid); + } + + public boolean isChanneling(Player player) { + return isChanneling(player.getUniqueId()); + } + public @Nullable Duration getDelayDuration() { return Duration.of(PluginConfig.TELEPORTATION.WAIT_TIME.getNotNull(), ChronoUnit.SECONDS); }