From 7885df35ae8ac61303d3f3329f212cdbcec2813f Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Thu, 21 Nov 2013 23:32:41 -0800 Subject: [PATCH] Added spectating flag for EntityTNTPrimed --- .../mineplex/serverstatus/ServerStatus.java | 55 ++++++---- .../server/v1_6_R3/EntityTNTPrimed.java | 102 ++++++++++++++++++ 2 files changed, 138 insertions(+), 19 deletions(-) create mode 100644 Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_6_R3/EntityTNTPrimed.java diff --git a/Plugins/Mineplex.ServerStatus/src/mineplex/serverstatus/ServerStatus.java b/Plugins/Mineplex.ServerStatus/src/mineplex/serverstatus/ServerStatus.java index 7c74dbab8..69187a421 100644 --- a/Plugins/Mineplex.ServerStatus/src/mineplex/serverstatus/ServerStatus.java +++ b/Plugins/Mineplex.ServerStatus/src/mineplex/serverstatus/ServerStatus.java @@ -94,7 +94,7 @@ public class ServerStatus } } */ - List screenNames = getScreenNames(); + List folderNames = getFolderNames(); //removeExcessFolders(screenNames); @@ -109,22 +109,8 @@ public class ServerStatus { try { - process = new ProcessBuilder(new String[] { "cd", "/home/mineplex/servers/", "rm", "-Rf", screen }).start(); + process = new ProcessBuilder(new String[] { "rm", "-Rf", "/home/mineplex/servers/" + screen }).start(); process.waitFor(); - BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream())); - String line = reader.readLine(); - - while(line != null) - { - int stopIndex = line.contains("(Detached)") ? line.indexOf("(Detached)") : line.contains("(Detached)") ? line.indexOf("(Attached)") : -1; - - if (stopIndex != -1) - { - //screens.add(line.substring(line.indexOf(".") + 1, stopIndex).trim()); - } - - line=reader.readLine(); - } } catch (Exception e) { @@ -204,14 +190,15 @@ public class ServerStatus */ } - private static List getScreenNames() + private static List getFolderNames() { Process process = null; List screens = new ArrayList(); + List folderNames = new ArrayList(); try { - process = new ProcessBuilder(new String[] { "cd", "/home/mineplex/servers/", "ls", "screen", "-list" }).start(); + process = new ProcessBuilder(new String[] { "screen", "-list" }).start(); process.waitFor(); BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream())); String line = reader.readLine(); @@ -240,6 +227,36 @@ public class ServerStatus } } - return screens; + try + { + process = new ProcessBuilder(new String[] { "ls", "/home/mineplex/servers" }).start(); + process.waitFor(); + BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream())); + String line = reader.readLine(); + + while(line != null) + { + for (String folderName : line.split(" ")) + { + if (!screens.contains(folderName.trim()) && !folderName.equalsIgnoreCase("Arenas")) + folderNames.add(folderName.trim()); + } + + line=reader.readLine(); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + finally + { + if (process != null) + { + process.destroy(); + } + } + + return folderNames; } } diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_6_R3/EntityTNTPrimed.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_6_R3/EntityTNTPrimed.java new file mode 100644 index 000000000..ab8b6fedf --- /dev/null +++ b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_6_R3/EntityTNTPrimed.java @@ -0,0 +1,102 @@ +package net.minecraft.server.v1_6_R3; + +import org.bukkit.craftbukkit.v1_6_R3.CraftServer; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity; +import org.bukkit.entity.Explosive; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.plugin.PluginManager; + +public class EntityTNTPrimed extends Entity +{ + public int fuseTicks; + private EntityLiving source; + public float yield = 4.0F; + public boolean isIncendiary = false; + + public boolean spectating = false; + + public EntityTNTPrimed(World world) { + super(world); + this.m = true; + a(0.98F, 0.98F); + this.height = (this.length / 2.0F); + } + + public EntityTNTPrimed(World world, double d0, double d1, double d2, EntityLiving entityliving) { + this(world); + setPosition(d0, d1, d2); + float f = (float)(Math.random() * 3.141592741012573D * 2.0D); + + this.motX = (-(float)Math.sin(f) * 0.02F); + this.motY = 0.2000000029802322D; + this.motZ = (-(float)Math.cos(f) * 0.02F); + this.fuseTicks = 80; + this.lastX = d0; + this.lastY = d1; + this.lastZ = d2; + this.source = entityliving; + } + protected void a() { + } + + protected boolean e_() { + return false; + } + + public boolean L() { + return !this.dead && !spectating; + } + + public void l_() { + this.lastX = this.locX; + this.lastY = this.locY; + this.lastZ = this.locZ; + this.motY -= 0.03999999910593033D; + move(this.motX, this.motY, this.motZ); + this.motX *= 0.9800000190734863D; + this.motY *= 0.9800000190734863D; + this.motZ *= 0.9800000190734863D; + if (this.onGround) { + this.motX *= 0.699999988079071D; + this.motZ *= 0.699999988079071D; + this.motY *= -0.5D; + } + + if (this.fuseTicks-- <= 0) + { + if (!this.world.isStatic) { + explode(); + } + die(); + } + else { + this.world.addParticle("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D); + } + } + + private void explode() + { + CraftServer server = this.world.getServer(); + + ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive)CraftEntity.getEntity(server, this)); + server.getPluginManager().callEvent(event); + + if (!event.isCancelled()) + { + this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), true); + } + } + + protected void b(NBTTagCompound nbttagcompound) + { + nbttagcompound.setByte("Fuse", (byte)this.fuseTicks); + } + + protected void a(NBTTagCompound nbttagcompound) { + this.fuseTicks = nbttagcompound.getByte("Fuse"); + } + + public EntityLiving getSource() { + return this.source; + } +} \ No newline at end of file