mirror of
https://github.com/darverdevs/BossBarAPI.git
synced 2024-12-21 23:04:11 -08:00
Added a teleport timer
This commit is contained in:
parent
c10abbe228
commit
08c4cec910
10
.idea/runConfigurations.xml
Normal file
10
.idea/runConfigurations.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -1,6 +1,7 @@
|
|||
package tech.nully.BossBarAPI;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -20,6 +21,8 @@ public class BossBar {
|
|||
return bossHealth;
|
||||
}
|
||||
|
||||
private TeleportScheduler t;
|
||||
|
||||
public void setHealth(int bossHealth) {
|
||||
this.bossHealth = bossHealth;
|
||||
if (dragon != null) {
|
||||
|
@ -48,17 +51,20 @@ public class BossBar {
|
|||
dragon.destroy();
|
||||
}
|
||||
}
|
||||
dragon = new SpawnFakeWither.FakeWither(
|
||||
new Location(p.getWorld(), p.getLocation().getX(), -15, p.getLocation().getZ()), ProtocolLibrary.getProtocolManager());
|
||||
dragon = new SpawnFakeWither.FakeWither(p, ProtocolLibrary.getProtocolManager());
|
||||
dragon.setCustomName(text);
|
||||
dragon.setVisible(false);
|
||||
dragon.create();
|
||||
|
||||
t = new TeleportScheduler(this);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), t, 100);
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
if (dragon != null) {
|
||||
if (dragon.created) {
|
||||
dragon.destroy();
|
||||
t.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
16
src/main/java/tech/nully/BossBarAPI/TeleportScheduler.java
Normal file
16
src/main/java/tech/nully/BossBarAPI/TeleportScheduler.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package tech.nully.BossBarAPI;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class TeleportScheduler extends BukkitRunnable {
|
||||
private BossBar b;
|
||||
|
||||
public TeleportScheduler(BossBar b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
b.display();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user