1
mirror of https://github.com/CarmJos/MoeTeleport.git synced 2024-09-19 21:35:56 +00:00

feat(effect): 支持简单的传送粒子效果

This commit is contained in:
Carm Jos 2023-02-14 23:06:02 +08:00
parent eaa83a89d1
commit bc14c39d68
4 changed files with 40 additions and 4 deletions

11
pom.xml
View File

@ -175,6 +175,13 @@
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>xyz.xenondevs</groupId>
<artifactId>particle</artifactId>
<version>1.8.3</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
@ -313,6 +320,10 @@
<pattern>org.bstats</pattern> <pattern>org.bstats</pattern>
<shadedPattern>cc.carm.plugin.moeteleport.lib.bstats</shadedPattern> <shadedPattern>cc.carm.plugin.moeteleport.lib.bstats</shadedPattern>
</relocation> </relocation>
<relocation>
<pattern>xyz.xenondevs.particle</pattern>
<shadedPattern>cc.carm.plugin.moeteleport.lib.praticle</shadedPattern>
</relocation>
<relocation> <relocation>
<pattern>org.json</pattern> <pattern>org.json</pattern>
<shadedPattern>cc.carm.plugin.moeteleport.lib.json</shadedPattern> <shadedPattern>cc.carm.plugin.moeteleport.lib.json</shadedPattern>

View File

@ -15,6 +15,7 @@ import cc.carm.plugin.moeteleport.storage.StorageMethod;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie; import org.bstats.charts.SimplePie;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import xyz.xenondevs.particle.utils.ReflectionUtils;
public class Main extends EasyPlugin { public class Main extends EasyPlugin {
private static Main instance; private static Main instance;
@ -34,7 +35,7 @@ public class Main extends EasyPlugin {
} }
@Override @Override
protected boolean initialize() { protected void load() {
log("加载插件配置文件..."); log("加载插件配置文件...");
this.configProvider = MineConfiguration.from(this, "config.yml"); 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 = MineConfiguration.from(this, "messages.yml");
this.messageProvider.initialize(PluginMessages.class); this.messageProvider.initialize(PluginMessages.class);
}
@Override
protected boolean initialize() {
log("初始化存储方式..."); log("初始化存储方式...");
StorageMethod storageMethod = StorageMethod.read(PluginConfig.STORAGE.METHOD.get()); StorageMethod storageMethod = StorageMethod.read(PluginConfig.STORAGE.METHOD.get());
@ -56,7 +62,6 @@ public class Main extends EasyPlugin {
return false; // 初始化失败不再继续加载 return false; // 初始化失败不再继续加载
} }
log("加载地标管理器..."); log("加载地标管理器...");
warpManager = new WarpManager(); warpManager = new WarpManager();
@ -90,7 +95,6 @@ public class Main extends EasyPlugin {
e.printStackTrace(); e.printStackTrace();
} }
if (PluginConfig.METRICS.getNotNull()) { if (PluginConfig.METRICS.getNotNull()) {
log("启用统计数据..."); log("启用统计数据...");
Metrics metrics = new Metrics(this, 14459); Metrics metrics = new Metrics(this, 14459);
@ -104,6 +108,9 @@ public class Main extends EasyPlugin {
log("已禁用检查更新,跳过。"); log("已禁用检查更新,跳过。");
} }
log("初始化粒子库...");
ReflectionUtils.setPlugin(this);
return true; return true;
} }

View File

@ -23,7 +23,7 @@ public class TeleportListener implements Listener {
if (from.getBlockX() == to.getBlockX() if (from.getBlockX() == to.getBlockX()
&& from.getBlockY() == to.getBlockY() && from.getBlockY() == to.getBlockY()
&& from.getBlockZ() == to.getBlockZ()){ && from.getBlockZ() == to.getBlockZ()) {
return; return;
} }

View File

@ -12,6 +12,8 @@ import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.particle.ParticleBuilder;
import xyz.xenondevs.particle.ParticleEffect;
import java.time.Duration; import java.time.Duration;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
@ -42,6 +44,8 @@ public class TeleportManager {
} }
public void tickQueue() { public void tickQueue() {
boolean enableEffect = PluginConfig.TELEPORTATION.EFFECTS.getNotNull();
Iterator<Map.Entry<UUID, TeleportQueue>> queueIterator = teleportQueue.entrySet().iterator(); Iterator<Map.Entry<UUID, TeleportQueue>> queueIterator = teleportQueue.entrySet().iterator();
while (queueIterator.hasNext()) { while (queueIterator.hasNext()) {
Map.Entry<UUID, TeleportQueue> entry = queueIterator.next(); Map.Entry<UUID, TeleportQueue> entry = queueIterator.next();
@ -52,6 +56,12 @@ public class TeleportManager {
queue.getPlayer(), queue.getPlayer(),
queue.getRemainSeconds() + 1, queue.getTarget().getText() queue.getRemainSeconds() + 1, queue.getTarget().getText()
); );
if (enableEffect) {
new ParticleBuilder(ParticleEffect.PORTAL, queue.getPlayer().getLocation())
.setAmount(100).display();
}
continue; continue;
} }
@ -74,6 +84,14 @@ public class TeleportManager {
return getQueue(player.getUniqueId()); 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() { public @Nullable Duration getDelayDuration() {
return Duration.of(PluginConfig.TELEPORTATION.WAIT_TIME.getNotNull(), ChronoUnit.SECONDS); return Duration.of(PluginConfig.TELEPORTATION.WAIT_TIME.getNotNull(), ChronoUnit.SECONDS);
} }