From 5e8077112f642091e8cefb01531c3e9fd406703f Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot <noreply+git-craftbukkit@papermc.io> Date: Wed, 26 Jan 2011 12:03:54 -0800 Subject: [PATCH 1/6] Added methods to get a list of entities to World. This replies on net.minecraft.server.Entity.bukkitEntity not being null (otherwise it won't be returned). By: sk89q <the.sk89q@gmail.com> --- .../org/bukkit/craftbukkit/CraftWorld.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index e4989c4e8a..ce456411aa 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -3,8 +3,11 @@ package org.bukkit.craftbukkit; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.entity.*; import org.bukkit.entity.*; +import org.bukkit.entity.Entity; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Random; import net.minecraft.server.*; @@ -316,4 +319,46 @@ public class CraftWorld implements World { return hash; } } + + @Override + public List<Entity> getEntities() { + List<Entity> list = new ArrayList<Entity>(); + + for (Object o : world.b) { + if (o instanceof net.minecraft.server.Entity) { + net.minecraft.server.Entity mcEnt + = (net.minecraft.server.Entity)o; + + Entity bukkitEntity = mcEnt.getBukkitEntity(); + + // Assuming that bukkitEntity isn't null + if (bukkitEntity != null) { + list.add(bukkitEntity); + } + } + } + + return list; + } + + @Override + public List<LivingEntity> getLivingEntities() { + List<LivingEntity> list = new ArrayList<LivingEntity>(); + + for (Object o : world.b) { + if (o instanceof net.minecraft.server.Entity) { + net.minecraft.server.Entity mcEnt + = (net.minecraft.server.Entity)o; + + Entity bukkitEntity = mcEnt.getBukkitEntity(); + + // Assuming that bukkitEntity isn't null + if (bukkitEntity != null && bukkitEntity instanceof LivingEntity) { + list.add((LivingEntity)bukkitEntity); + } + } + } + + return list; + } } From ccf32b63ef9d3d5c0a32a98da41b9926c46eb9ce Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot <noreply+git-craftbukkit@papermc.io> Date: Thu, 27 Jan 2011 13:26:37 +0000 Subject: [PATCH 2/6] You don't override for interfaces! By: Dinnerbone <dinnerbone@dinnerbone.com> --- .../src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index ce456411aa..cdeffc3a7a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -320,7 +320,6 @@ public class CraftWorld implements World { } } - @Override public List<Entity> getEntities() { List<Entity> list = new ArrayList<Entity>(); @@ -341,7 +340,6 @@ public class CraftWorld implements World { return list; } - @Override public List<LivingEntity> getLivingEntities() { List<LivingEntity> list = new ArrayList<LivingEntity>(); From 78473d2dd4d1ccca84eff808c82f4ea1e35b5f40 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot <noreply+git-craftbukkit@papermc.io> Date: Thu, 27 Jan 2011 16:15:41 -0500 Subject: [PATCH 3/6] onDisable on stop - stephank By: Taylor Kelly <tkelly910@gmail.com> --- .../src/main/java/org/bukkit/craftbukkit/CraftServer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 68c9eb593a..8368d377f7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -52,6 +52,10 @@ public final class CraftServer implements Server { } } + public void disablePlugins() { + pluginManager.disablePlugins(); + } + private void loadPlugin(Plugin plugin) { List<Command> pluginCommands = PluginCommandYamlParser.parse(plugin); if (!pluginCommands.isEmpty()) { From 991af11e0b3cc0e0feb463a0b5834882c7b0de5a Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot <noreply+git-craftbukkit@papermc.io> Date: Fri, 28 Jan 2011 09:15:32 +0000 Subject: [PATCH 4/6] Implemented player.performCommand(String) By: Dinnerbone <dinnerbone@dinnerbone.com> --- .../main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index a1ed1165ed..2ceb8d9781 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -106,4 +106,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { entity.a.b(((Packet) (new Packet6SpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())))); } + public boolean performCommand(String command) { + return server.dispatchCommand(this, command); + } } From 89b83951232783aa33d1dde91cedfc43fe58a172 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot <noreply+git-craftbukkit@papermc.io> Date: Fri, 28 Jan 2011 14:18:49 +0000 Subject: [PATCH 5/6] server.reload() now reloads plugins By: Dinnerbone <dinnerbone@dinnerbone.com> --- .../src/main/java/org/bukkit/craftbukkit/CraftServer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 8368d377f7..250e0ff2e8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -175,5 +175,9 @@ public final class CraftServer implements Server { console.e.k = monsters ? 1 : 0; console.e.a(monsters, animals); + + pluginManager.clearPlugins(); + commandMap.clearCommands(); + loadPlugins(); } } From 6eb906ae20fb63bbe93f8fc89e4f588097b9514a Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot <noreply+git-craftbukkit@papermc.io> Date: Fri, 28 Jan 2011 10:24:53 -0800 Subject: [PATCH 6/6] Added Block.isBlockPowered(), block.isBlockIndirectlyPowered(). By: sk89q <the.sk89q@gmail.com> --- .../java/org/bukkit/craftbukkit/block/CraftBlock.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 4c00089685..4d19e34b6b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -337,6 +337,14 @@ public class CraftBlock implements Block { return null; } + public boolean isBlockPowered() { + return world.getHandle().o(x, y, z); + } + + public boolean isBlockIndirectlyPowered() { + return world.getHandle().p(x, y, z); + } + public void update() { type = world.getHandle().a(x, y, z); data = (byte)world.getHandle().b(x, y, z);