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,16 +23,13 @@ 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
|
// Count down
|
||||||
public void run() {
|
bar.setHealth(bar.getHealth() - 1);
|
||||||
// Count down
|
|
||||||
bar.setHealth(bar.getHealth() - 1);
|
|
||||||
|
|
||||||
if (bar.getHealth() <= 0) {
|
if (bar.getHealth() <= 0) {
|
||||||
bar.delete();
|
bar.delete();
|
||||||
task.cancel();
|
task.cancel();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, TICKS_PER_SECOND / 4, TICKS_PER_SECOND / 4);
|
}, TICKS_PER_SECOND / 4, TICKS_PER_SECOND / 4);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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() {
|
||||||
|
@ -70,7 +72,7 @@ public class SpawnFakeWither extends JavaPlugin {
|
||||||
if (created) {
|
if (created) {
|
||||||
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
||||||
|
|
||||||
watcher.setObject(METADATA_FLAGS, visible ? (byte)0 : INVISIBLE);
|
watcher.setObject(METADATA_FLAGS, visible ? (byte) 0 : INVISIBLE);
|
||||||
sendMetadata(watcher);
|
sendMetadata(watcher);
|
||||||
}
|
}
|
||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
|
@ -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() {
|
||||||
|
@ -110,7 +116,7 @@ public class SpawnFakeWither extends JavaPlugin {
|
||||||
Packet18SpawnMob spawnMob = new Packet18SpawnMob();
|
Packet18SpawnMob spawnMob = new Packet18SpawnMob();
|
||||||
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
||||||
|
|
||||||
watcher.setObject(METADATA_FLAGS, visible ? (byte)0 : INVISIBLE);
|
watcher.setObject(METADATA_FLAGS, visible ? (byte) 0 : INVISIBLE);
|
||||||
watcher.setObject(METADATA_WITHER_HEALTH, (int) health); // 1.5.2 -> Change to (int)
|
watcher.setObject(METADATA_WITHER_HEALTH, (int) health); // 1.5.2 -> Change to (int)
|
||||||
|
|
||||||
if (customName != null) {
|
if (customName != null) {
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,23 +144,14 @@ public class SpawnFakeWither extends JavaPlugin {
|
||||||
throw new IllegalStateException("Cannot kill a killed entity.");
|
throw new IllegalStateException("Cannot kill a killed entity.");
|
||||||
|
|
||||||
Packet1DDestroyEntity destroyMe = new Packet1DDestroyEntity();
|
Packet1DDestroyEntity destroyMe = new Packet1DDestroyEntity();
|
||||||
destroyMe.setEntities(new int[] { id });
|
destroyMe.setEntities(new int[]{id});
|
||||||
|
|
||||||
broadcastPacket(destroyMe.getHandle(), false);
|
try {
|
||||||
created = false;
|
manager.sendServerPacket(p, destroyMe.getHandle());
|
||||||
}
|
} catch (InvocationTargetException e) {
|
||||||
|
Bukkit.getLogger().log(Level.WARNING, "Cannot send " + destroyMe.getHandle() + " to " + p, e);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
created = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user