use of org.bukkit.boss.BossBar in project Denizen-For-Bukkit by DenizenScript.
the class PlayerHelper_v1_11_R1 method removeSimpleBossBar.
@Override
public void removeSimpleBossBar(Player player) {
UUID uuid = player.getUniqueId();
if (bossBars.containsKey(uuid) && !bossBars.get(uuid).isEmpty()) {
Iterator<BossBar> iterator = bossBars.get(uuid).iterator();
while (iterator.hasNext()) {
BossBar bossBar = iterator.next();
bossBar.removePlayer(player);
iterator.remove();
}
}
}
use of org.bukkit.boss.BossBar in project Denizen-For-Bukkit by DenizenScript.
the class PlayerHelper_v1_10_R1 method removeSimpleBossBar.
@Override
public void removeSimpleBossBar(Player player) {
UUID uuid = player.getUniqueId();
if (bossBars.containsKey(uuid) && !bossBars.get(uuid).isEmpty()) {
Iterator<BossBar> iterator = bossBars.get(uuid).iterator();
while (iterator.hasNext()) {
BossBar bossBar = iterator.next();
bossBar.removePlayer(player);
iterator.remove();
}
}
}
use of org.bukkit.boss.BossBar in project Denizen-For-Bukkit by DenizenScript.
the class BossBarCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
Element id = scriptEntry.getElement("id");
Element action = scriptEntry.getElement("action");
dList players = scriptEntry.getdObject("players");
Element title = scriptEntry.getElement("title");
Element progress = scriptEntry.getElement("progress");
Element color = scriptEntry.getElement("color");
Element style = scriptEntry.getElement("style");
dList flags = scriptEntry.getdObject("flags");
dB.report(scriptEntry, getName(), id.debug() + action.debug() + (players != null ? players.debug() : "") + (title != null ? title.debug() : "") + (progress != null ? progress.debug() : "") + (color != null ? color.debug() : "") + (style != null ? style.debug() : "") + (flags != null ? flags.debug() : ""));
String idString = CoreUtilities.toLowerCase(id.asString());
switch(Action.valueOf(action.asString().toUpperCase())) {
case CREATE:
if (bossBarMap.containsKey(idString)) {
dB.echoError("BossBar '" + idString + "' already exists!");
return;
}
String barTitle = title != null ? title.asString() : "";
List<dPlayer> barPlayers = players.filter(dPlayer.class);
double barProgress = progress != null ? progress.asDouble() : 1D;
BarColor barColor = color != null ? BarColor.valueOf(color.asString().toUpperCase()) : BarColor.WHITE;
BarStyle barStyle = style != null ? BarStyle.valueOf(style.asString().toUpperCase()) : BarStyle.SOLID;
BarFlag[] barFlags = new BarFlag[flags != null ? flags.size() : 0];
if (flags != null) {
for (int i = 0; i < flags.size(); i++) {
barFlags[i] = (BarFlag.valueOf(flags.get(i).toUpperCase()));
}
}
BossBar bossBar = Bukkit.createBossBar(barTitle, barColor, barStyle, barFlags);
bossBar.setProgress(barProgress);
for (dPlayer player : barPlayers) {
if (!player.isOnline()) {
dB.echoError("Player must be online to show a BossBar to them!");
continue;
}
bossBar.addPlayer(player.getPlayerEntity());
}
bossBar.setVisible(true);
bossBarMap.put(idString, bossBar);
break;
case UPDATE:
if (!bossBarMap.containsKey(idString)) {
dB.echoError("BossBar '" + idString + "' does not exist!");
return;
}
BossBar bossBar1 = bossBarMap.get(idString);
if (title != null) {
bossBar1.setTitle(title.asString());
}
if (progress != null) {
bossBar1.setProgress(progress.asDouble());
}
if (color != null) {
bossBar1.setColor(BarColor.valueOf(color.asString().toUpperCase()));
}
if (style != null) {
bossBar1.setStyle(BarStyle.valueOf(style.asString().toUpperCase()));
}
if (players != null) {
for (dPlayer player : players.filter(dPlayer.class)) {
bossBar1.addPlayer(player.getPlayerEntity());
}
}
break;
case REMOVE:
if (!bossBarMap.containsKey(idString)) {
dB.echoError("BossBar '" + idString + "' does not exist!");
return;
}
if (players != null) {
BossBar bar = bossBarMap.get(idString);
for (dPlayer player : players.filter(dPlayer.class)) {
bar.removePlayer(player.getPlayerEntity());
}
break;
}
bossBarMap.get(idString).setVisible(false);
bossBarMap.remove(idString);
break;
}
}
use of org.bukkit.boss.BossBar in project VehiclesPlus2.0 by legofreak107.
the class Boat method Boat.
public static void Boat(PacketPlayInSteerVehicle ppisv, Player p) {
ArmorStand a2 = (ArmorStand) p.getVehicle();
a2.setGravity(false);
Seat s = plugin.seatInfo.get(a2);
ArmorStand a = (ArmorStand) s.parent;
Vehicle v = plugin.vehicleInfo.get(a);
v.holder.setGravity(false);
if (p.getOpenInventory() != null && p.getOpenInventory() instanceof PlayerInventory) {
p.openInventory(v.inv);
}
float forward = ppisv.b();
float side = ppisv.a();
if (v.fuelbar == null) {
BossBar b = Bukkit.createBossBar("fuel" + v.owner, BarColor.GREEN, BarStyle.SOLID);
v.fuelbar = b;
}
Location tloc = a2.getLocation().clone();
Location smoke = tloc.add(tloc.getDirection().setY(0).normalize().multiply(-1.5));
smoke.getWorld().spawnParticle(Particle.SMOKE_LARGE, smoke.getX(), smoke.getY() + 1, smoke.getZ(), 1, 0, 0, 0, 0);
v.fuelbar.setTitle("Fuel: " + (int) (v.fuel / v.maxFuel * 100) + "%");
v.fuelbar.setProgress((v.fuel / v.maxFuel));
if (!v.parts.ENGINE) {
} else {
if (v.fuelbar.getPlayers().contains(p)) {
} else {
v.fuelbar.addPlayer(p);
v.fuelbar.setVisible(true);
}
if (v.fuel <= 0.5) {
v.fuelbar.setTitle("Out of fuel!");
} else {
v.fuel -= v.fualUsage / 2;
if (forward > 0) {
// Forward[W]
int broken = randInt(0, 20000);
int brokenEngine = randInt(0, 20000);
if (brokenEngine == 0) {
v.parts.ENGINE = false;
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 10, 10);
p.sendMessage("�2It looks like you have blown up your engine...");
}
v.fuel -= v.fualUsage / 2;
if (v.curSpeed <= v.fspeed || v.curSpeed == 0) {
v.curSpeed = v.curSpeed += v.acceleration / 2;
}
Location fb = v.holder.getLocation().add(v.holder.getLocation().getDirection().setY(0).normalize().multiply(4));
float z1 = (float) (fb.getZ() + (4 * Math.sin(Math.toRadians(fb.getYaw() + 90 * 0))));
float x1 = (float) (fb.getX() + (4 * Math.cos(Math.toRadians(fb.getYaw() + 90 * 0))));
float z2 = (float) (fb.getZ() + (-4 * Math.sin(Math.toRadians(fb.getYaw() + 90 * 0))));
float x2 = (float) (fb.getX() + (-4 * Math.cos(Math.toRadians(fb.getYaw() + 90 * 0))));
Location loc1 = new Location(fb.getWorld(), x1, fb.getY(), z1);
Location loc2 = new Location(fb.getWorld(), x2, fb.getY(), z2);
if (fb.getBlock().getType() == Material.STATIONARY_WATER) {
if (side > 0) {
// Side[A]
if (loc1.getBlock().getType() == Material.STATIONARY_WATER && loc2.getBlock().getType() == Material.STATIONARY_WATER) {
v.skinHolder.setHeadPose(new EulerAngle(0, 0, 170));
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
Location loc = a.getLocation().clone();
loc.setYaw(loc.getYaw() + 90);
a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() - v.turnSpeed, a.getLocation().getPitch());
a1.move(EnumMoveType.SELF, new Vector(loc.getDirection().multiply(0.5).getX(), 0, loc.getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(loc.getDirection().multiply(0.5).getX(), 0, loc.getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), new Vector(loc.getDirection().multiply(0.5).getX(), 0, loc.getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
a1.move(EnumMoveType.SELF, new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
v.steering = (int) (v.turnSpeed / 2);
}
} else if (side < 0) {
// Side[D]
if (loc1.getBlock().getType() == Material.STATIONARY_WATER && loc2.getBlock().getType() == Material.STATIONARY_WATER) {
v.skinHolder.setHeadPose(new EulerAngle(0, 0, -170));
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
Location loc = a.getLocation().clone();
loc.setYaw(loc.getYaw() - 90);
a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() + v.turnSpeed, a.getLocation().getPitch());
a1.move(EnumMoveType.SELF, new Vector(loc.getDirection().multiply(0.5).getX(), 0, loc.getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(loc.getDirection().multiply(0.5).getX(), 0, loc.getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), new Vector(loc.getDirection().multiply(0.5).getX(), 0, loc.getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
a1.move(EnumMoveType.SELF, new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
v.steering = -(int) (v.turnSpeed / 2);
}
} else {
v.steering = 0;
v.skinHolder.setHeadPose(new EulerAngle(0, 0, 0));
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.move(EnumMoveType.SELF, new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
}
} else {
v.curSpeed = 0;
}
} else if (forward < 0) {
// Reverse[S]
Location fb = v.holder.getLocation().add(v.holder.getLocation().getDirection().setY(0).normalize().multiply(-4));
float z1 = (float) (fb.getZ() + (4 * Math.sin(Math.toRadians(fb.getYaw() + 90 * 0))));
float x1 = (float) (fb.getX() + (4 * Math.cos(Math.toRadians(fb.getYaw() + 90 * 0))));
float z2 = (float) (fb.getZ() + (-4 * Math.sin(Math.toRadians(fb.getYaw() + 90 * 0))));
float x2 = (float) (fb.getX() + (-4 * Math.cos(Math.toRadians(fb.getYaw() + 90 * 0))));
Location loc1 = new Location(fb.getWorld(), x1, fb.getY(), z1);
Location loc2 = new Location(fb.getWorld(), x2, fb.getY(), z2);
if (fb.getBlock().getType() == Material.STATIONARY_WATER) {
v.skinHolder.setHeadPose(new EulerAngle(0, 0, 0));
v.fuel -= v.fualUsage / 2;
Location loc3 = new Location(a.getWorld(), a.getLocation().getBlockX(), a.getLocation().getBlockY(), a.getLocation().getBlockZ() + 1);
Location loc4 = new Location(a.getWorld(), a.getLocation().getBlockX(), a.getLocation().getBlockY(), a.getLocation().getBlockZ() - 1);
Location loc5 = new Location(a.getWorld(), a.getLocation().getBlockX() - 1, a.getLocation().getBlockY(), a.getLocation().getBlockZ());
if (v.curSpeed >= -v.bspeed || v.curSpeed == 0) {
v.curSpeed = v.curSpeed -= v.acceleration * 2;
}
if ((loc1.getBlock().getType() != Material.AIR && loc1.getBlock().getType() != Material.LONG_GRASS && loc1.getBlock().getType() != Material.CHORUS_FLOWER && loc1.getBlock().getType() != Material.YELLOW_FLOWER && loc1.getBlock().getType() != Material.RED_ROSE && loc1.getBlock().getType() != Material.WHEAT) || (loc2.getBlock().getType() != Material.AIR && loc2.getBlock().getType() != Material.LONG_GRASS && loc2.getBlock().getType() != Material.CHORUS_FLOWER && loc2.getBlock().getType() != Material.YELLOW_FLOWER && loc2.getBlock().getType() != Material.RED_ROSE && loc2.getBlock().getType() != Material.WHEAT) || (loc3.getBlock().getType() != Material.AIR && loc3.getBlock().getType() != Material.LONG_GRASS && loc3.getBlock().getType() != Material.CHORUS_FLOWER && loc3.getBlock().getType() != Material.YELLOW_FLOWER && loc3.getBlock().getType() != Material.RED_ROSE && loc3.getBlock().getType() != Material.WHEAT) || (loc4.getBlock().getType() != Material.AIR && loc4.getBlock().getType() != Material.LONG_GRASS && loc4.getBlock().getType() != Material.CHORUS_FLOWER && loc4.getBlock().getType() != Material.YELLOW_FLOWER && loc4.getBlock().getType() != Material.RED_ROSE && loc4.getBlock().getType() != Material.WHEAT) && loc5.getBlock().getType() != Material.AIR) {
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.move(EnumMoveType.SELF, new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), // a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -1, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(- BwdDriveSpeed.get(a.getUniqueId())));
new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
} else {
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.move(EnumMoveType.SELF, new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
}
if (side > 0) {
// Side[A]
if (loc1.getBlock().getType() == Material.STATIONARY_WATER && loc2.getBlock().getType() == Material.STATIONARY_WATER) {
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() + v.turnSpeed, a.getLocation().getPitch());
v.steering = (int) (v.turnSpeed / 2);
}
} else if (side < 0) {
// Side[D]
if (loc1.getBlock().getType() == Material.STATIONARY_WATER && loc2.getBlock().getType() == Material.STATIONARY_WATER) {
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() - v.turnSpeed, a.getLocation().getPitch());
v.steering = -(int) (v.turnSpeed / 2);
}
} else {
v.steering = 0;
v.skinHolder.setHeadPose(new EulerAngle(0, 0, 0));
}
} else {
v.curSpeed = 0;
}
} else {
v.steering = 0;
if (v.curSpeed > v.acceleration) {
v.curSpeed = v.curSpeed -= v.acceleration;
} else if (v.curSpeed < -v.acceleration) {
v.curSpeed = v.curSpeed += v.acceleration;
} else {
v.curSpeed = 0;
}
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
Location fb = v.holder.getLocation().add(v.holder.getLocation().getDirection().setY(0).normalize().multiply(4));
Location fb2 = v.holder.getLocation().add(v.holder.getLocation().getDirection().setY(0).normalize().multiply(-4));
if (fb.getBlock().getType() == Material.STATIONARY_WATER && fb2.getBlock().getType() == Material.STATIONARY_WATER) {
a1.move(EnumMoveType.SELF, new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getX(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getY(), new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed).getZ());
} else {
v.curSpeed = 0;
}
}
}
}
}
use of org.bukkit.boss.BossBar in project VehiclesPlus2.0 by legofreak107.
the class Vehicle method spawn.
public void spawn() {
VPPlayer pl = new VPPlayer();
pl.p = Bukkit.getPlayer(owner);
p = pl;
Location l = spawnLoc;
id = plugin.lastid;
plugin.lastid++;
BossBar b = Bukkit.createBossBar("fuel" + owner, BarColor.GREEN, BarStyle.SOLID);
fuelbar = b;
VehicleParts pa = new VehicleParts();
pa.ENGINE = true;
pa.WHEELFL = true;
pa.WHEELFR = true;
pa.WHEELRL = true;
pa.WHEELRR = true;
parts = pa;
ArmorStand carrier = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
carrier.setCustomName(id + name);
carrier.setVisible(false);
ArmorStand skin1 = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
skin1.setSmall(true);
skin1.setAI(false);
skin1.setCollidable(false);
skin1.setCustomName(id + owner + ".id" + id + "skin");
skin1.setHelmet(skin);
skin1.setVisible(false);
skin1.setGravity(false);
holder = carrier;
skinHolder = skin1;
ArrayList<Seat> al = new ArrayList<Seat>();
for (Seat s : seats) {
Seat s2 = s;
ArmorStand seat = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
seat.setSmall(true);
seat.setCustomName(id + owner + ".id" + id + "seat");
seat.setGravity(false);
seat.setAI(true);
seat.setCollidable(true);
seat.setVisible(false);
s2.parent = carrier;
s2.seat = seat;
al.add(s2);
plugin.seatInfo.put(seat, s2);
}
seats = al;
plugin.vehicleInfo.put(carrier, this);
if (plugin.playerVehicles.containsKey(Bukkit.getPlayer(owner))) {
List<Vehicle> v = plugin.playerVehicles.get(Bukkit.getPlayer(owner));
v.add(this);
plugin.playerVehicles.put(Bukkit.getPlayer(owner), v);
} else {
List<Vehicle> v = new ArrayList<Vehicle>();
v.add(this);
plugin.playerVehicles.put(Bukkit.getPlayer(owner), v);
}
}
Aggregations