Skip to content

Commit 08c4cec

Browse files
committed
Added a teleport timer
1 parent c10abbe commit 08c4cec

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

.idea/runConfigurations.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/tech/nully/BossBarAPI/BossBar.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package tech.nully.BossBarAPI;
22

33
import com.comphenix.protocol.ProtocolLibrary;
4+
import org.bukkit.Bukkit;
45
import org.bukkit.Location;
56
import org.bukkit.entity.Player;
67

@@ -20,6 +21,8 @@ public int getHealth() {
2021
return bossHealth;
2122
}
2223

24+
private TeleportScheduler t;
25+
2326
public void setHealth(int bossHealth) {
2427
this.bossHealth = bossHealth;
2528
if (dragon != null) {
@@ -48,17 +51,20 @@ public void display() {
4851
dragon.destroy();
4952
}
5053
}
51-
dragon = new SpawnFakeWither.FakeWither(
52-
new Location(p.getWorld(), p.getLocation().getX(), -15, p.getLocation().getZ()), ProtocolLibrary.getProtocolManager());
54+
dragon = new SpawnFakeWither.FakeWither(p, ProtocolLibrary.getProtocolManager());
5355
dragon.setCustomName(text);
5456
dragon.setVisible(false);
5557
dragon.create();
58+
59+
t = new TeleportScheduler(this);
60+
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), t, 100);
5661
}
5762

5863
public void delete() {
5964
if (dragon != null) {
6065
if (dragon.created) {
6166
dragon.destroy();
67+
t.cancel();
6268
}
6369
}
6470
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package tech.nully.BossBarAPI;
2+
3+
import org.bukkit.scheduler.BukkitRunnable;
4+
5+
public class TeleportScheduler extends BukkitRunnable {
6+
private BossBar b;
7+
8+
public TeleportScheduler(BossBar b) {
9+
this.b = b;
10+
}
11+
12+
@Override
13+
public void run() {
14+
b.display();
15+
}
16+
}

0 commit comments

Comments
 (0)