Skip to content

Commit

Permalink
feat(effect): 支持简单的传送粒子效果
Browse files Browse the repository at this point in the history
  • Loading branch information
CarmJos committed Feb 14, 2023
1 parent eaa83a8 commit bc14c39
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@
<optional>true</optional>
</dependency>

<dependency>
<groupId>xyz.xenondevs</groupId>
<artifactId>particle</artifactId>
<version>1.8.3</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.spigotmc</groupId>
Expand Down Expand Up @@ -313,6 +320,10 @@
<pattern>org.bstats</pattern>
<shadedPattern>cc.carm.plugin.moeteleport.lib.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>xyz.xenondevs.particle</pattern>
<shadedPattern>cc.carm.plugin.moeteleport.lib.praticle</shadedPattern>
</relocation>
<relocation>
<pattern>org.json</pattern>
<shadedPattern>cc.carm.plugin.moeteleport.lib.json</shadedPattern>
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/cc/carm/plugin/moeteleport/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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;
Expand All @@ -34,7 +35,7 @@ public Main() {
}

@Override
protected boolean initialize() {
protected void load() {

log("加载插件配置文件...");
this.configProvider = MineConfiguration.from(this, "config.yml");
Expand All @@ -43,6 +44,11 @@ protected boolean initialize() {
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());

Expand All @@ -56,7 +62,6 @@ protected boolean initialize() {
return false; // 初始化失败,不再继续加载
}


log("加载地标管理器...");
warpManager = new WarpManager();

Expand Down Expand Up @@ -90,7 +95,6 @@ protected boolean initialize() {
e.printStackTrace();
}


if (PluginConfig.METRICS.getNotNull()) {
log("启用统计数据...");
Metrics metrics = new Metrics(this, 14459);
Expand All @@ -104,6 +108,9 @@ protected boolean initialize() {
log("已禁用检查更新,跳过。");
}

log("初始化粒子库...");
ReflectionUtils.setPlugin(this);

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void onMove(PlayerMoveEvent event) {

if (from.getBlockX() == to.getBlockX()
&& from.getBlockY() == to.getBlockY()
&& from.getBlockZ() == to.getBlockZ()){
&& from.getBlockZ() == to.getBlockZ()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
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;
Expand Down Expand Up @@ -42,6 +44,8 @@ public void shutdown() {
}

public void tickQueue() {
boolean enableEffect = PluginConfig.TELEPORTATION.EFFECTS.getNotNull();

Iterator<Map.Entry<UUID, TeleportQueue>> queueIterator = teleportQueue.entrySet().iterator();
while (queueIterator.hasNext()) {
Map.Entry<UUID, TeleportQueue> entry = queueIterator.next();
Expand All @@ -52,6 +56,12 @@ public void tickQueue() {
queue.getPlayer(),
queue.getRemainSeconds() + 1, queue.getTarget().getText()
);

if (enableEffect) {
new ParticleBuilder(ParticleEffect.PORTAL, queue.getPlayer().getLocation())
.setAmount(100).display();
}

continue;
}

Expand All @@ -74,6 +84,14 @@ public TeleportQueue getQueue(Player player) {
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);
}
Expand Down

0 comments on commit bc14c39

Please sign in to comment.