mirror of
https://github.com/darverdevs/BossBarAPI.git
synced 2024-12-22 07:14:11 -08:00
stuff
This commit is contained in:
parent
683a57af8f
commit
cb4affa931
|
@ -1,10 +0,0 @@
|
||||||
<?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>
|
|
|
@ -63,8 +63,8 @@ public class BossBar {
|
||||||
public void delete() {
|
public void delete() {
|
||||||
if (dragon != null) {
|
if (dragon != null) {
|
||||||
if (dragon.created) {
|
if (dragon.created) {
|
||||||
dragon.destroy();
|
|
||||||
t.cancel();
|
t.cancel();
|
||||||
|
dragon.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,7 @@ public class FakeWitherCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
|
||||||
// Count down
|
// Count down
|
||||||
task = Bukkit.getServer().getScheduler().runTaskTimer(Main.getInstance(), new Runnable() {
|
task = Bukkit.getServer().getScheduler().runTaskTimer(Main.getInstance(), () -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
// Count down
|
// Count down
|
||||||
bar.setHealth(bar.getHealth() - 1);
|
bar.setHealth(bar.getHealth() - 1);
|
||||||
|
|
||||||
|
@ -33,7 +31,6 @@ public class FakeWitherCommand implements CommandExecutor {
|
||||||
bar.delete();
|
bar.delete();
|
||||||
task.cancel();
|
task.cancel();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, TICKS_PER_SECOND / 4, TICKS_PER_SECOND / 4);
|
}, TICKS_PER_SECOND / 4, TICKS_PER_SECOND / 4);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -44,10 +44,12 @@ public class SpawnFakeWither extends JavaPlugin {
|
||||||
|
|
||||||
public Location location;
|
public Location location;
|
||||||
public ProtocolManager manager;
|
public ProtocolManager manager;
|
||||||
|
public Player p;
|
||||||
|
|
||||||
public FakeWither(Player p, ProtocolManager manager) {
|
public FakeWither(Player p, ProtocolManager manager) {
|
||||||
this.location = new Location(p.getWorld(), p.getLocation().getX(), -5, p.getLocation().getZ());
|
this.location = new Location(p.getWorld(), p.getLocation().getX(), -5, p.getLocation().getZ());
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
|
this.p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHealth() {
|
public int getHealth() {
|
||||||
|
@ -99,7 +101,11 @@ public class SpawnFakeWither extends JavaPlugin {
|
||||||
|
|
||||||
update.setEntityId(id);
|
update.setEntityId(id);
|
||||||
update.setEntityMetadata(watcher.getWatchableObjects());
|
update.setEntityMetadata(watcher.getWatchableObjects());
|
||||||
broadcastPacket(update.getHandle(), true);
|
try {
|
||||||
|
manager.sendServerPacket(p, update.getHandle());
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
Bukkit.getLogger().log(Level.WARNING, "Cannot send " + update.getHandle() + " to " + p, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
|
@ -125,7 +131,11 @@ public class SpawnFakeWither extends JavaPlugin {
|
||||||
spawnMob.setZ(location.getZ());
|
spawnMob.setZ(location.getZ());
|
||||||
spawnMob.setMetadata(watcher);
|
spawnMob.setMetadata(watcher);
|
||||||
|
|
||||||
broadcastPacket(spawnMob.getHandle(), true);
|
try {
|
||||||
|
manager.sendServerPacket(p, spawnMob.getHandle());
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
Bukkit.getLogger().log(Level.WARNING, "Cannot send " + spawnMob.getHandle() + " to " + p, e);
|
||||||
|
}
|
||||||
created = true;
|
created = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,21 +146,12 @@ public class SpawnFakeWither extends JavaPlugin {
|
||||||
Packet1DDestroyEntity destroyMe = new Packet1DDestroyEntity();
|
Packet1DDestroyEntity destroyMe = new Packet1DDestroyEntity();
|
||||||
destroyMe.setEntities(new int[]{id});
|
destroyMe.setEntities(new int[]{id});
|
||||||
|
|
||||||
broadcastPacket(destroyMe.getHandle(), false);
|
try {
|
||||||
|
manager.sendServerPacket(p, destroyMe.getHandle());
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
Bukkit.getLogger().log(Level.WARNING, "Cannot send " + destroyMe.getHandle() + " to " + p, e);
|
||||||
|
}
|
||||||
created = false;
|
created = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void broadcastPacket(PacketContainer packet, boolean onlyNearby) {
|
|
||||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
|
||||||
// Must be within the range
|
|
||||||
if (!onlyNearby || player.getLocation().distanceSquared(location) < HEALTH_RANGE) {
|
|
||||||
try {
|
|
||||||
manager.sendServerPacket(player, packet);
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Cannot send " + packet + " to " + player, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user