Merged in FabioZumbi12/herobrine-for-bukkit-or-spigot (pull request #4)

Fixes and improvement!
This commit is contained in:
David Berdik 2015-10-19 15:32:52 -04:00
commit 0b399bec88
5 changed files with 36 additions and 11 deletions

View File

@ -5,11 +5,8 @@ import java.util.logging.Logger;
import net.theprogrammersworld.herobrine.HerobrineAI; import net.theprogrammersworld.herobrine.HerobrineAI;
import net.theprogrammersworld.herobrine.AI.AICore; import net.theprogrammersworld.herobrine.AI.AICore;
import net.theprogrammersworld.herobrine.AI.Core; import net.theprogrammersworld.herobrine.AI.Core;
import net.theprogrammersworld.herobrine.nms.NPC.entity.HumanNPC;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -431,7 +428,7 @@ public class CmdExecutor implements CommandExecutor {
args[1])); args[1]));
String pname = args[1]; String pname = args[1];
Player target = Bukkit.getPlayer(pname); Player target = Bukkit.getPlayer(pname);
P_Core.herobrineNPC.lookAtPoint(target.getLocation()); HerobrineAI.herobrineNPC.lookAtPoint(target.getLocation());
player.sendMessage(ChatColor.RED player.sendMessage(ChatColor.RED
+ "[Herobrine] Herobrine is now haunting " + "[Herobrine] Herobrine is now haunting "
+ args[1] + "."); + args[1] + ".");
@ -850,13 +847,13 @@ public class CmdExecutor implements CommandExecutor {
log.info("[Herobrine] Herobrine configuration file reloaded."); log.info("[Herobrine] Herobrine configuration file reloaded.");
} else if (args[0].equalsIgnoreCase("position")) { } else if (args[0].equalsIgnoreCase("position")) {
// TODO: Position // TODO: Position
double x = P_Core.herobrineNPC.getNMSEntity().locX; double x = HerobrineAI.herobrineNPC.getNMSEntity().locX;
double y = P_Core.herobrineNPC.getNMSEntity().locY; double y = HerobrineAI.herobrineNPC.getNMSEntity().locY;
double z = P_Core.herobrineNPC.getNMSEntity().locZ; double z = HerobrineAI.herobrineNPC.getNMSEntity().locZ;
net.minecraft.server.v1_8_R3.World world = P_Core.herobrineNPC.getNMSEntity().getWorld(); net.minecraft.server.v1_8_R3.World world = HerobrineAI.herobrineNPC.getNMSEntity().getWorld();
sender.sendMessage(red + "Herobrine's location world: " + red sender.sendMessage(red + "Herobrine's location world: " + red
+ world + red + " x: " + red + x + red + " y: " + red + world + red + " x: " + red + x + red + " y: " + red
+ y + red + " z: " + red + y); + y + red + " z: " + red + z);
} else if (args[0].equalsIgnoreCase("help")) { } else if (args[0].equalsIgnoreCase("help")) {
log.info("[Herobrine] Command List"); log.info("[Herobrine] Command List");

View File

@ -38,6 +38,8 @@ public class EntityListener implements Listener {
private ArrayList<String> getLore; private ArrayList<String> getLore;
public EntityListener(){ public EntityListener(){
equalsLore = new ArrayList<String>();
equalsLoreS = new ArrayList<String>();
equalsLore.add("Herobrine´s artifact"); equalsLore.add("Herobrine´s artifact");
equalsLore.add("Bow of Teleporting"); equalsLore.add("Bow of Teleporting");
equalsLoreS.add("Herobrine´s artifact"); equalsLoreS.add("Herobrine´s artifact");
@ -196,7 +198,7 @@ public class EntityListener implements Listener {
{ {
this.itemInHand = player.getItemInHand(); this.itemInHand = player.getItemInHand();
this.getLore = ItemName.getLore(this.itemInHand); this.getLore = ItemName.getLore(this.itemInHand);
if ((this.getLore.containsAll(this.equalsLoreS)) && (HerobrineAI.getPluginCore().getConfigDB().UseArtifactSword) && (new Random().nextBoolean())) { if ((this.equalsLoreS != null) && (this.getLore.containsAll(this.equalsLoreS)) && (HerobrineAI.getPluginCore().getConfigDB().UseArtifactSword) && (new Random().nextBoolean())) {
player.getLocation().getWorld().strikeLightning(event.getEntity().getLocation()); player.getLocation().getWorld().strikeLightning(event.getEntity().getLocation());
} }
} }

View File

@ -181,8 +181,26 @@ public class PlayerListener implements Listener {
HerobrineAI.getPluginCore().getAICore().cancelTarget(Core.CoreType.RANDOM_POSITION); HerobrineAI.getPluginCore().getAICore().cancelTarget(Core.CoreType.RANDOM_POSITION);
HerobrineAI.herobrineNPC.moveTo(new Location(Bukkit.getServer().getWorlds().get(0), 0.0D, -20.0D, 0.0D)); HerobrineAI.herobrineNPC.moveTo(new Location(Bukkit.getServer().getWorlds().get(0), 0.0D, -20.0D, 0.0D));
} }
} else {
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(event.getTo().getWorld().getName()) || HerobrineAI.getPluginCore().getConfigDB().HerobrineWorldName.equalsIgnoreCase(event.getTo().getWorld().getName())){
addHerobrine(event.getPlayer());
} else {
delHerobrine(event.getPlayer());
} }
} }
}
private void addHerobrine(Player player){
EntityPlayer p = ((CraftPlayer) player).getHandle();
p.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, HerobrineAI.herobrineNPC.getNMSEntity()));
}
private void delHerobrine(Player player){
EntityPlayer p = ((CraftPlayer) player).getHandle();
p.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, HerobrineAI.herobrineNPC.getNMSEntity()));
}
@EventHandler @EventHandler
public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { public void onPlayerCommand(final PlayerCommandPreprocessEvent event) {
@ -213,8 +231,14 @@ public class PlayerListener implements Listener {
@EventHandler @EventHandler
public void onJoin(PlayerJoinEvent event) { public void onJoin(PlayerJoinEvent event) {
if (HerobrineAI.getPluginCore().getConfigDB().useWorlds.contains(event.getPlayer().getWorld().getName()) ||
HerobrineAI.getPluginCore().getConfigDB().HerobrineWorldName.equalsIgnoreCase(event.getPlayer().getWorld().getName())){
addHerobrine(event.getPlayer());
}
/*
EntityPlayer player = ((CraftPlayer) event.getPlayer()).getHandle(); EntityPlayer player = ((CraftPlayer) event.getPlayer()).getHandle();
player.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, HerobrineAI.herobrineNPC.getNMSEntity())); player.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, HerobrineAI.herobrineNPC.getNMSEntity()));
*/
} }
} }

View File

@ -15,6 +15,7 @@ public class NetworkHandler extends PlayerConnection {
public void a(final double d0, final double d1, final double d2, final float f, final float f1) { public void a(final double d0, final double d1, final double d2, final float f, final float f1) {
} }
@SuppressWarnings("rawtypes")
@Override @Override
public void sendPacket(final Packet packet) { public void sendPacket(final Packet packet) {
} }

View File

@ -9,6 +9,7 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@SuppressWarnings("rawtypes")
public class NetworkUtils { public class NetworkUtils {
public static void sendPacketNearby(final Location location, final Packet packet) { public static void sendPacketNearby(final Location location, final Packet packet) {