From 411b35d74fffe0faec6ecd7ec20b24b977640ba4 Mon Sep 17 00:00:00 2001
From: Spigot <noreply+git-spigot@papermc.io>
Date: Fri, 5 Jul 2013 12:17:22 +1000
Subject: [PATCH] Pull a series of CraftBukkit patches - see below for summary
 and credits:

Bukkit/CraftBukkit#1145 : @Zarius : Don't fire piston extend event twice
Bukkit/CraftBukkit#1174 : @millerkil : Prevent plugins causing ghost players
Bukkit/CraftBukkit#1177 : @jb-aero : Properly set ambient flag for potion effects

By: md_5 <md_5@live.com.au>
---
 ...2-Don-t-Fire-PistonExtendEvent-Twice.patch | 22 +++++++++++
 ...vent-Ghost-Players-Caused-by-Plugins.patch | 24 ++++++++++++
 ...ne-Ambient-Setting-of-Potion-Effects.patch | 39 +++++++++++++++++++
 3 files changed, 85 insertions(+)
 create mode 100644 CraftBukkit-Patches/0062-Don-t-Fire-PistonExtendEvent-Twice.patch
 create mode 100644 CraftBukkit-Patches/0063-Prevent-Ghost-Players-Caused-by-Plugins.patch
 create mode 100644 CraftBukkit-Patches/0064-Define-Ambient-Setting-of-Potion-Effects.patch

diff --git a/CraftBukkit-Patches/0062-Don-t-Fire-PistonExtendEvent-Twice.patch b/CraftBukkit-Patches/0062-Don-t-Fire-PistonExtendEvent-Twice.patch
new file mode 100644
index 0000000000..a026ad3890
--- /dev/null
+++ b/CraftBukkit-Patches/0062-Don-t-Fire-PistonExtendEvent-Twice.patch
@@ -0,0 +1,22 @@
+From 3f3055e1d22a5e282a55b2e522c747ba02aee471 Mon Sep 17 00:00:00 2001
+From: Zarius <zariust@gmail.com>
+Date: Thu, 25 Apr 2013 03:08:24 +1000
+Subject: [PATCH] Don't Fire PistonExtendEvent Twice
+
+Set data earlier for BlockPiston when extending. Fixes BUKKIT-3523
+
+diff --git a/src/main/java/net/minecraft/server/BlockPiston.java b/src/main/java/net/minecraft/server/BlockPiston.java
+index 2d9e766..b2c8499 100644
+--- a/src/main/java/net/minecraft/server/BlockPiston.java
++++ b/src/main/java/net/minecraft/server/BlockPiston.java
+@@ -71,6 +71,7 @@ public class BlockPiston extends Block {
+                     if (event.isCancelled()) {
+                         return;
+                     }
++                    world.setData(i, j, k, i1 | 8, 2);
+                     // CraftBukkit end
+ 
+                     world.playNote(i, j, k, this.id, 0, i1);
+-- 
+1.8.1.2
+
diff --git a/CraftBukkit-Patches/0063-Prevent-Ghost-Players-Caused-by-Plugins.patch b/CraftBukkit-Patches/0063-Prevent-Ghost-Players-Caused-by-Plugins.patch
new file mode 100644
index 0000000000..83458cfa5c
--- /dev/null
+++ b/CraftBukkit-Patches/0063-Prevent-Ghost-Players-Caused-by-Plugins.patch
@@ -0,0 +1,24 @@
+From 43802c41faf4edae4752b4ab06cb36ab19ef2e35 Mon Sep 17 00:00:00 2001
+From: Alex Ciuba <alexciuba@gmail.com>
+Date: Tue, 11 Jun 2013 15:23:03 -0400
+Subject: [PATCH] Prevent Ghost Players Caused by Plugins
+
+Check if the player is still connected after firing event. Fixes BUKKIT-4327
+
+diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
+index cbe823f..f33fdc1 100644
+--- a/src/main/java/net/minecraft/server/PlayerList.java
++++ b/src/main/java/net/minecraft/server/PlayerList.java
+@@ -420,6 +420,9 @@ public abstract class PlayerList {
+             Player respawnPlayer = this.cserver.getPlayer(entityplayer1);
+             PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn);
+             this.cserver.getPluginManager().callEvent(respawnEvent);
++            if (entityplayer.playerConnection.disconnected) {
++                return entityplayer;
++            }
+ 
+             location = respawnEvent.getRespawnLocation();
+             entityplayer.reset();
+-- 
+1.8.1.2
+
diff --git a/CraftBukkit-Patches/0064-Define-Ambient-Setting-of-Potion-Effects.patch b/CraftBukkit-Patches/0064-Define-Ambient-Setting-of-Potion-Effects.patch
new file mode 100644
index 0000000000..1c6fe36257
--- /dev/null
+++ b/CraftBukkit-Patches/0064-Define-Ambient-Setting-of-Potion-Effects.patch
@@ -0,0 +1,39 @@
+From 183a4c8ebcc8c7b52496fbe4cba25a8bb58e7676 Mon Sep 17 00:00:00 2001
+From: Jim Bilbrey <jb_aero@verizon.net>
+Date: Wed, 19 Jun 2013 05:38:05 -0400
+Subject: [PATCH] Define Ambient Setting of Potion Effects
+
+Use ambient setting of potion effects. Fixes BUKKIT-4357 and BUKKIT-3653
+
+This changes livingEntity.addPotionEffect(PotionEffect, boolean) to
+construct the MobEffect using the constructor that includes the ambient
+setting as supplied by the PotionEffect
+
+This also changes livingEntity.getActivePotionEffects() to construct the
+PotionEffects using the ambient setting supplied by the MobEffects.
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+index 1d52866..9d9320f 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+@@ -258,7 +258,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
+             }
+             removePotionEffect(effect.getType());
+         }
+-        getHandle().addEffect(new MobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier()));
++        getHandle().addEffect(new MobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient()));
+         return true;
+     }
+ 
+@@ -284,7 +284,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
+             if (!(raw instanceof MobEffect))
+                 continue;
+             MobEffect handle = (MobEffect) raw;
+-            effects.add(new PotionEffect(PotionEffectType.getById(handle.getEffectId()), handle.getDuration(), handle.getAmplifier()));
++            effects.add(new PotionEffect(PotionEffectType.getById(handle.getEffectId()), handle.getDuration(), handle.getAmplifier(), handle.isAmbient()));
+         }
+         return effects;
+     }
+-- 
+1.8.1.2
+