Implementation of richer playEffect methods. Addresses BUKKIT-857

By: Celtic Minstrel <celtic.minstrel.ca@some.place>
This commit is contained in:
CraftBukkit/Spigot
2012-02-26 13:24:25 -05:00
parent 27ab478e59
commit a3dccca671
3 changed files with 96 additions and 0 deletions

View File

@@ -14,12 +14,16 @@ import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.*;
import org.apache.commons.lang.Validate;
import org.bukkit.*;
import org.bukkit.Achievement;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.configuration.serialization.DelegateDeserialization;
import org.bukkit.craftbukkit.CraftEffect;
import org.bukkit.craftbukkit.CraftOfflinePlayer;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
@@ -33,6 +37,7 @@ import org.bukkit.map.MapView;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.messaging.StandardMessenger;
import org.bukkit.potion.Potion;
@DelegateDeserialization(CraftOfflinePlayer.class)
public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -227,6 +232,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
getHandle().netServerHandler.sendPacket(packet);
}
public <T> void playEffect(Location loc, Effect effect, T data) {
if (data != null) {
Validate.isTrue(data.getClass().equals(effect.getData()), "Wrong kind of data for this effect!");
} else {
Validate.isTrue(effect.getData() == null, "Wrong kind of data for this effect!");
}
int datavalue = data == null ? 0 : CraftEffect.getDataValue(effect, data);
playEffect(loc, effect, datavalue);
}
public void sendBlockChange(Location loc, Material material, byte data) {
sendBlockChange(loc, material.getId(), data);
}