Changes from SnD branch

This commit is contained in:
libraryaddict 2015-10-30 19:25:02 +13:00
parent ed18588a6a
commit ea1e4b79f7
14 changed files with 478 additions and 394 deletions

View File

@ -52,6 +52,7 @@ public class Hologram
private HologramTarget _target = HologramTarget.BLACKLIST;
private int _viewDistance = 70;
protected Vector relativeToEntity;
private boolean _hideBoundingBox;
public Hologram(HologramManager hologramManager, Location location, String... text)
{
@ -77,6 +78,17 @@ public class Hologram
return this;
}
/**
* Warning! Bounding box if hidden will hide holograms for 1.8 to 1.8.2
*
* @return
*/
public Hologram setHideBoundingBox()
{
_hideBoundingBox = true;
return this;
}
/**
* Is there a player entry in the hologram for Whitelist and Blacklist
*/
@ -268,7 +280,7 @@ public class Hologram
packet.a = entityId;
packet.b = 30;
packet.c = (int) (getLocation().getX() * 32);
packet.d = (int) ((getLocation().getY() + -2.1 + ((double) textRow * 0.285)) * 32);
packet.d = (int) ((getLocation().getY() + (_hideBoundingBox ? 0 : -2.1) + ((double) textRow * 0.285)) * 32);
packet.e = (int) (getLocation().getZ() * 32);
packet.l = watcher;
@ -276,7 +288,11 @@ public class Hologram
watcher.a(0, (byte) 32);
watcher.a(2, lineOfText);
watcher.a(3, (byte) 1);
// watcher.a(10, (byte) 16); // TODO Uncomment after we can enforce 1.8.3
if (_hideBoundingBox)
{
watcher.a(10, (byte) 16); // TODO Uncomment after we can enforce 1.8.3
}
// Also correct hologram positioning
return new Packet[]

View File

@ -9,9 +9,11 @@ import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkEffectMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.SkullMeta;
@ -20,349 +22,376 @@ import org.bukkit.potion.Potion;
public class ItemBuilder
{
private static ArrayList<String> split(String string, int maxLength)
{
String[] split = string.split(" ");
string = "";
ArrayList<String> newString = new ArrayList<String>();
for (int i = 0; i < split.length; i++)
{
string += (string.length() == 0 ? "" : " ") + split[i];
if (ChatColor.stripColor(string).length() > maxLength)
{
newString
.add((newString.size() > 0 ? ChatColor.getLastColors(newString.get(newString.size() - 1)) : "") + string);
string = "";
}
}
if (string.length() > 0)
newString.add((newString.size() > 0 ? ChatColor.getLastColors(newString.get(newString.size() - 1)) : "") + string);
return newString;
}
private static ArrayList<String> split(String string, int maxLength)
{
String[] split = string.split(" ");
string = "";
ArrayList<String> newString = new ArrayList<String>();
for (int i = 0; i < split.length; i++)
{
string += (string.length() == 0 ? "" : " ") + split[i];
if (ChatColor.stripColor(string).length() > maxLength)
{
newString
.add((newString.size() > 0 ? ChatColor.getLastColors(newString.get(newString.size() - 1)) : "") + string);
string = "";
}
}
if (string.length() > 0)
newString.add((newString.size() > 0 ? ChatColor.getLastColors(newString.get(newString.size() - 1)) : "") + string);
return newString;
}
private int _amount;
private Color _color;
private short _data;
private final HashMap<Enchantment, Integer> _enchants = new HashMap<Enchantment, Integer>();
private final List<String> _lore = new ArrayList<String>();
private Material _mat;
// private Potion potion;
private String _title = null;
private boolean _unbreakable;
private int _amount;
private Color _color;
private short _data;
private final HashMap<Enchantment, Integer> _enchants = new HashMap<Enchantment, Integer>();
private final List<String> _lore = new ArrayList<String>();
private Material _mat;
// private Potion potion;
private String _title = null;
private boolean _unbreakable;
private String _playerHeadName = null;
public ItemBuilder(ItemStack item)
{
this(item.getType(), item.getDurability());
this._amount = item.getAmount();
this._enchants.putAll(item.getEnchantments());
if (item.getType() == Material.POTION)
{
// setPotion(Potion.fromItemStack(item));
}
if (item.hasItemMeta())
{
ItemMeta meta = item.getItemMeta();
if (meta.hasDisplayName())
{
this._title = meta.getDisplayName();
}
if (meta.hasLore())
{
this._lore.addAll(meta.getLore());
}
if (meta instanceof LeatherArmorMeta)
{
this.setColor(((LeatherArmorMeta) meta).getColor());
}
this._unbreakable = meta.spigot().isUnbreakable();
}
}
public ItemBuilder(ItemStack item)
{
this(item.getType(), item.getDurability());
_amount = item.getAmount();
_enchants.putAll(item.getEnchantments());
if (item.getType() == Material.POTION)
{
// setPotion(Potion.fromItemStack(item));
}
if (item.hasItemMeta())
{
ItemMeta meta = item.getItemMeta();
public ItemBuilder(Material mat)
{
this(mat, 1);
}
if (meta.hasDisplayName())
{
_title = meta.getDisplayName();
}
public ItemBuilder(Material mat, int amount)
{
this(mat, amount, (short) 0);
}
if (meta.hasLore())
{
_lore.addAll(meta.getLore());
}
public ItemBuilder(Material mat, int amount, short data)
{
this._mat = mat;
this._amount = amount;
this._data = data;
}
if (meta instanceof LeatherArmorMeta)
{
setColor(((LeatherArmorMeta) meta).getColor());
}
public ItemBuilder(Material mat, short data)
{
this(mat, 1, data);
}
_unbreakable = meta.spigot().isUnbreakable();
}
}
public ItemBuilder addEnchantment(Enchantment enchant, int level)
{
if (_enchants.containsKey(enchant))
{
_enchants.remove(enchant);
}
_enchants.put(enchant, level);
return this;
}
public ItemBuilder(Material mat)
{
this(mat, 1);
}
public ItemBuilder addLore(String... lores)
{
for (String lore : lores)
{
this._lore.add(ChatColor.GRAY + lore);
}
return this;
}
public ItemBuilder(Material mat, int amount)
{
this(mat, amount, (short) 0);
}
public ItemBuilder addLore(String lore, int maxLength)
{
this._lore.addAll(split(lore, maxLength));
return this;
}
public ItemBuilder(Material mat, int amount, short data)
{
_mat = mat;
_amount = amount;
_data = data;
}
public ItemBuilder addLores(List<String> lores)
{
this._lore.addAll(lores);
return this;
}
public ItemBuilder(Material mat, short data)
{
this(mat, 1, data);
}
public ItemBuilder addLores(List<String> lores, int maxLength)
{
for (String lore : lores)
{
addLore(lore, maxLength);
}
return this;
}
public ItemBuilder addEnchantment(Enchantment enchant, int level)
{
if (_enchants.containsKey(enchant))
{
_enchants.remove(enchant);
}
_enchants.put(enchant, level);
return this;
}
public ItemBuilder addLores(String[] description, int maxLength)
{
return addLores(Arrays.asList(description), maxLength);
}
public ItemBuilder addLore(String... lores)
{
for (String lore : lores)
{
_lore.add(ChatColor.GRAY + lore);
}
return this;
}
public ItemStack build()
{
Material mat = this._mat;
if (mat == null)
{
mat = Material.AIR;
Bukkit.getLogger().warning("Null material!");
}
else if (mat == Material.AIR)
{
Bukkit.getLogger().warning("Air material!");
}
ItemStack item = new ItemStack(mat, this._amount, this._data);
ItemMeta meta = item.getItemMeta();
if (meta != null)
{
if (this._title != null)
{
meta.setDisplayName(this._title);
}
if (!this._lore.isEmpty())
{
meta.setLore(this._lore);
}
if (meta instanceof LeatherArmorMeta)
{
((LeatherArmorMeta) meta).setColor(this._color);
}
public ItemBuilder addLore(String lore, int maxLength)
{
_lore.addAll(split(lore, maxLength));
return this;
}
public ItemBuilder addLores(List<String> lores)
{
_lore.addAll(lores);
return this;
}
public ItemBuilder addLores(List<String> lores, int maxLength)
{
for (String lore : lores)
{
addLore(lore, maxLength);
}
return this;
}
public ItemBuilder addLores(String[] description, int maxLength)
{
return addLores(Arrays.asList(description), maxLength);
}
public ItemStack build()
{
Material mat = _mat;
if (mat == null)
{
mat = Material.AIR;
Bukkit.getLogger().warning("Null material!");
}
else if (mat == Material.AIR)
{
Bukkit.getLogger().warning("Air material!");
}
ItemStack item = new ItemStack(mat, _amount, _data);
ItemMeta meta = item.getItemMeta();
if (meta != null)
{
if (_title != null)
{
meta.setDisplayName(_title);
}
if (!_lore.isEmpty())
{
meta.setLore(_lore);
}
if (meta instanceof LeatherArmorMeta && _color != null)
{
((LeatherArmorMeta) meta).setColor(_color);
}
else if (meta instanceof SkullMeta && _playerHeadName != null)
{
((SkullMeta) meta).setOwner(_playerHeadName);
}
meta.spigot().setUnbreakable(isUnbreakable());
item.setItemMeta(meta);
}
item.addUnsafeEnchantments(this._enchants);
// if (this.potion != null) {
// this.potion.apply(item);
// }
return item;
}
else if (meta instanceof FireworkEffectMeta && _color != null)
{
((FireworkEffectMeta) meta).setEffect(FireworkEffect.builder().withColor(_color).build());
}
@Override
public ItemBuilder clone()
{
ItemBuilder newBuilder = new ItemBuilder(this._mat);
meta.spigot().setUnbreakable(isUnbreakable());
item.setItemMeta(meta);
}
newBuilder.setTitle(this._title);
for (String lore : this._lore)
{
newBuilder.addLore(lore);
}
for (Map.Entry<Enchantment, Integer> entry : this._enchants.entrySet())
{
newBuilder.addEnchantment(entry.getKey(), entry.getValue());
}
newBuilder.setColor(this._color);
// newBuilder.potion = this.potion;
item.addUnsafeEnchantments(_enchants);
// if (potion != null) {
// potion.apply(item);
// }
return item;
}
return newBuilder;
}
@Override
public ItemBuilder clone()
{
ItemBuilder newBuilder = new ItemBuilder(_mat);
public HashMap<Enchantment, Integer> getAllEnchantments()
{
return this._enchants;
}
newBuilder.setTitle(_title);
public Color getColor()
{
return this._color;
}
for (String lore : _lore)
{
newBuilder.addLore(lore);
}
public short getData()
{
return this._data;
}
for (Map.Entry<Enchantment, Integer> entry : _enchants.entrySet())
{
newBuilder.addEnchantment(entry.getKey(), entry.getValue());
}
public int getEnchantmentLevel(Enchantment enchant)
{
return this._enchants.get(enchant);
}
newBuilder.setColor(_color);
// newBuilder.potion = potion;
public List<String> getLore()
{
return this._lore;
}
return newBuilder;
}
public String getTitle()
{
return this._title;
}
public HashMap<Enchantment, Integer> getAllEnchantments()
{
return _enchants;
}
public Material getType()
{
return this._mat;
}
public Color getColor()
{
return _color;
}
public boolean hasEnchantment(Enchantment enchant)
{
return this._enchants.containsKey(enchant);
}
public short getData()
{
return _data;
}
public boolean isItem(ItemStack item)
{
ItemMeta meta = item.getItemMeta();
if (item.getType() != this.getType())
{
return false;
}
if (!meta.hasDisplayName() && this.getTitle() != null)
{
return false;
}
if (!meta.getDisplayName().equals(this.getTitle()))
{
return false;
}
if (!meta.hasLore() && !this.getLore().isEmpty())
{
return false;
}
if (meta.hasLore())
{
for (String lore : meta.getLore())
{
if (!this.getLore().contains(lore))
{
return false;
}
}
}
for (Enchantment enchant : item.getEnchantments().keySet())
{
if (!this.hasEnchantment(enchant))
{
return false;
}
}
return true;
}
public int getEnchantmentLevel(Enchantment enchant)
{
return _enchants.get(enchant);
}
public boolean isUnbreakable()
{
return this._unbreakable;
}
public List<String> getLore()
{
return _lore;
}
public ItemBuilder setAmount(int amount)
{
this._amount = amount;
return this;
}
public String getTitle()
{
return _title;
}
public ItemBuilder setColor(Color color)
{
if (!this._mat.name().contains("LEATHER_"))
{
throw new IllegalArgumentException("Can only dye leather armor!");
}
this._color = color;
return this;
}
public Material getType()
{
return _mat;
}
public ItemBuilder setData(short newData)
{
this._data = newData;
return this;
}
public boolean hasEnchantment(Enchantment enchant)
{
return _enchants.containsKey(enchant);
}
public ItemBuilder setPotion(Potion potion)
{
if (this._mat != Material.POTION)
{
this._mat = Material.POTION;
}
// this.potion = potion;
return this;
}
public boolean isItem(ItemStack item)
{
ItemMeta meta = item.getItemMeta();
public ItemBuilder setRawTitle(String title)
{
this._title = title;
return this;
}
if (item.getType() != getType())
{
return false;
}
public ItemBuilder setTitle(String title)
{
this._title = (title == null ? null
: (title.length() > 2 && ChatColor.getLastColors(title.substring(0, 2)).length() == 0 ? ChatColor.WHITE : ""))
+ title;
return this;
}
if (!meta.hasDisplayName() && getTitle() != null)
{
return false;
}
public ItemBuilder setTitle(String title, int maxLength)
{
if (title != null && ChatColor.stripColor(title).length() > maxLength)
{
ArrayList<String> lores = split(title, maxLength);
for (int i = 1; i < lores.size(); i++)
{
this._lore.add(lores.get(i));
}
title = lores.get(0);
}
setTitle(title);
return this;
}
if (!meta.getDisplayName().equals(getTitle()))
{
return false;
}
public ItemBuilder setType(Material mat)
{
this._mat = mat;
return this;
}
if (!meta.hasLore() && !getLore().isEmpty())
{
return false;
}
public ItemBuilder setUnbreakable(boolean setUnbreakable)
{
this._unbreakable = setUnbreakable;return this;
}
if (meta.hasLore())
{
for (String lore : meta.getLore())
{
if (!getLore().contains(lore))
{
return false;
}
}
}
for (Enchantment enchant : item.getEnchantments().keySet())
{
if (!hasEnchantment(enchant))
{
return false;
}
}
return true;
}
public boolean isUnbreakable()
{
return _unbreakable;
}
public ItemBuilder setAmount(int amount)
{
_amount = amount;
return this;
}
public ItemBuilder setColor(Color color)
{
/* (!_mat.name().contains("LEATHER_"))
{
throw new IllegalArgumentException("Can only dye leather armor!");
}*/
_color = color;
return this;
}
public ItemBuilder setData(short newData)
{
_data = newData;
return this;
}
public ItemBuilder setPotion(Potion potion)
{
if (_mat != Material.POTION)
{
_mat = Material.POTION;
}
return this;
}
public ItemBuilder setRawTitle(String title)
{
_title = title;
return this;
}
public ItemBuilder setTitle(String title)
{
_title = (title == null ? null
: (title.length() > 2 && ChatColor.getLastColors(title.substring(0, 2)).length() == 0 ? ChatColor.WHITE : ""))
+ title;
return this;
}
public ItemBuilder setTitle(String title, int maxLength)
{
if (title != null && ChatColor.stripColor(title).length() > maxLength)
{
ArrayList<String> lores = split(title, maxLength);
for (int i = 1; i < lores.size(); i++)
{
_lore.add(lores.get(i));
}
title = lores.get(0);
}
setTitle(title);
return this;
}
public ItemBuilder setType(Material mat)
{
_mat = mat;
return this;
}
public ItemBuilder setUnbreakable(boolean setUnbreakable)
{
_unbreakable = setUnbreakable;
return this;
}
public ItemBuilder setPlayerHead(String playerName)
{

View File

@ -148,6 +148,7 @@ public class ProjectileManager extends MiniPlugin
if (cur.isDead() || !cur.isValid())
{
entry.getValue().getIThrown().Idle(entry.getValue());
iterator.remove();
continue;
}

View File

@ -288,6 +288,11 @@ public class ProjectileUser
return false;
}
public IThrown getIThrown()
{
return _callback;
}
public LivingEntity GetThrower()
{
return _thrower;

View File

@ -256,4 +256,25 @@ public class Recharge extends MiniPlugin
_recharge.get(player.getName()).get(ability).debug(player);
}
public void displayExpBar(Player player, String ability)
{
if (!_recharge.containsKey(player.getName()))
{
player.setExp(1F);
return;
}
RechargeData recharge = _recharge.get(player.getName()).get(ability);
if (recharge == null)
{
player.setExp(1F);
return;
}
float elasped = (float) (System.currentTimeMillis() - recharge.Time) / recharge.Recharge;
player.setExp(Math.max(Math.min(1, elasped), 0));
}
}

View File

@ -44,9 +44,9 @@ public class CustomDamageEvent extends Event implements Cancellable
private boolean _damageeBrute = false;
private boolean _damageToLevel = true;
public CustomDamageEvent(LivingEntity damagee, LivingEntity damager, Projectile projectile,
DamageCause cause, double damage, boolean knockback, boolean ignoreRate, boolean ignoreArmor,
String initialSource, String initialReason, boolean cancelled)
public CustomDamageEvent(LivingEntity damagee, LivingEntity damager, Projectile projectile, Location knockbackOrigin,
DamageCause cause, double damage, boolean knockback, boolean ignoreRate, boolean ignoreArmor, String initialSource,
String initialReason, boolean cancelled)
{
_eventCause = cause;
@ -73,6 +73,8 @@ public class CustomDamageEvent extends Event implements Cancellable
if (cancelled)
SetCancelled("Pre-Cancelled");
_knockbackOrigin = knockbackOrigin;
}
@Override

View File

@ -173,11 +173,16 @@ public class DamageManager extends MiniPlugin
public void NewDamageEvent(LivingEntity damagee, LivingEntity damager, Projectile proj,
DamageCause cause, double damage, boolean knockback, boolean ignoreRate, boolean ignoreArmor,
String source, String reason, boolean cancelled)
{
NewDamageEvent(damagee, damager, proj, null, cause, damage, knockback, ignoreRate, ignoreArmor, source, reason, cancelled);
}
public void NewDamageEvent(LivingEntity damagee, LivingEntity damager, Projectile proj, Location knockbackOrigin,
DamageCause cause, double damage, boolean knockback, boolean ignoreRate, boolean ignoreArmor,
String source, String reason, boolean cancelled)
{
_plugin.getServer().getPluginManager().callEvent(
new CustomDamageEvent(damagee, damager, proj, cause, damage,
knockback, ignoreRate, ignoreArmor,
source, reason, cancelled));
_plugin.getServer().getPluginManager().callEvent(new CustomDamageEvent(damagee, damager, proj, knockbackOrigin, cause,
damage, knockback, ignoreRate, ignoreArmor, source, reason, cancelled));
}
@EventHandler(priority = EventPriority.LOW)
@ -294,7 +299,7 @@ public class DamageManager extends MiniPlugin
if (e.equals(Enchantment.ARROW_KNOCKBACK) || e.equals(Enchantment.KNOCKBACK))
event.AddKnockback("Ench Knockback", 1 + (0.5 * (double)enchants.get(e)));
else if (e.equals(Enchantment.ARROW_DAMAGE))
else if (e.equals(Enchantment.ARROW_DAMAGE) || e.equals(Enchantment.DAMAGE_ALL))
event.AddMod("Enchant", "Ench Damage", 0.5 * (double)enchants.get(e), true);
else if (e.equals(Enchantment.ARROW_FIRE) || e.equals(Enchantment.FIRE_ASPECT))
@ -370,7 +375,7 @@ public class DamageManager extends MiniPlugin
((CraftLivingEntity)event.GetDamageeEntity()).getHandle().o(((CraftLivingEntity)event.GetDamageeEntity()).getHandle().bv() + 1);
//Knockback
if (event.IsKnockback() && event.GetDamagerEntity(true) != null)
if (event.IsKnockback() && (event.getKnockbackOrigin() != null || event.GetDamagerEntity(true) != null))
{
//Base
double knockback = event.GetDamage();
@ -382,9 +387,14 @@ public class DamageManager extends MiniPlugin
knockback = knockback * cur;
//Origin
Location origin = event.GetDamagerEntity(true).getLocation();
Location origin = null;
if (event.GetDamagerEntity(true) != null)
origin = event.GetDamagerEntity(true).getLocation();
if (event.getKnockbackOrigin() != null)
origin = event.getKnockbackOrigin();
else if (event.GetProjectile() != null)
origin = event.GetProjectile().getLocation();
//Vec
Vector trajectory = UtilAlg.getTrajectory2d(origin, event.GetDamageeEntity().getLocation());

View File

@ -87,6 +87,13 @@ public class CustomExplosion extends Explosion
return this;
}
public CustomExplosion setIgnoreNonLiving(boolean ignoreNonLiving)
{
_ignoreNonLiving = ignoreNonLiving;
return this;
}
public CustomExplosion setMaxDamage(float maxDamage)
{
_maxDamage = maxDamage;
@ -240,6 +247,9 @@ public class CustomExplosion extends Explosion
if (entity.getBukkitEntity() == _owner && !_damageOwner)
continue;
if (!(entity.getBukkitEntity() instanceof LivingEntity) && _ignoreNonLiving)
continue;
double d7 = entity.f(this.posX, this.posY, this.posZ) / this._size; // XXX
if (d7 <= 1.0D)
@ -272,8 +282,8 @@ public class CustomExplosion extends Explosion
if (entity.getBukkitEntity() instanceof LivingEntity)
{
_manager.NewDamageEvent((LivingEntity) entity.getBukkitEntity(), _owner, null,
DamageCause.ENTITY_EXPLOSION, damage, true, _ignoreRate, false, _damageReason, _damageReason);
_manager.NewDamageEvent((LivingEntity) entity.getBukkitEntity(), _owner, null, new Location(_world.getWorld(), posX, posY, posZ),
DamageCause.ENTITY_EXPLOSION, damage, true, _ignoreRate, false, _damageReason, _damageReason, false);
}
else
{

View File

@ -657,7 +657,10 @@ public abstract class Game implements Listener
HandlerList.unregisterAll(kit);
for (Perk perk : kit.GetPerks())
{
HandlerList.unregisterAll(perk);
perk.unregisteredEvents();
}
}
}

View File

@ -214,7 +214,7 @@ public class KitKnight extends SmashKit
Horse horse = (Horse)damagee.getVehicle();
//Damage Event
CustomDamageEvent newEvent = new CustomDamageEvent(horse, event.GetDamagerEntity(true), event.GetProjectile(),
CustomDamageEvent newEvent = new CustomDamageEvent(horse, event.GetDamagerEntity(true), event.GetProjectile(), null,
event.GetCause(), event.GetDamageInitial(), true, false, false,
UtilEnt.getName(event.GetDamagerPlayer(true)), event.GetReason(), false);
@ -246,7 +246,7 @@ public class KitKnight extends SmashKit
Player player = (Player)horse.getPassenger();
//Damage Event
final CustomDamageEvent newEvent = new CustomDamageEvent(player, event.GetDamagerEntity(true), event.GetProjectile(),
final CustomDamageEvent newEvent = new CustomDamageEvent(player, event.GetDamagerEntity(true), event.GetProjectile(), null,
event.GetCause(), event.GetDamageInitial(), true, false, false,
UtilEnt.getName(event.GetDamagerPlayer(true)), event.GetReason(), false);

View File

@ -153,7 +153,7 @@ public class SnowFight extends TeamGame
{
if(IsOnIce(player))
{
Bukkit.getPluginManager().callEvent(new CustomDamageEvent(player, null, null, DamageCause.CUSTOM, 2.0D, false, true, true, "Ice", "Ice", false));
Bukkit.getPluginManager().callEvent(new CustomDamageEvent(player, null, null, null, DamageCause.CUSTOM, 2.0D, false, true, true, "Ice", "Ice", false));
}
}
@ -510,7 +510,7 @@ public class SnowFight extends TeamGame
if(player instanceof Player)
{
Player damagee = (Player) player;
Bukkit.getPluginManager().callEvent(new CustomDamageEvent(damagee, null, null, DamageCause.CUSTOM, damage, false, true, true, "Ice Meteoroid", "Ice Meteoroid", false));
Bukkit.getPluginManager().callEvent(new CustomDamageEvent(damagee, null, null, null, DamageCause.CUSTOM, damage, false, true, true, "Ice Meteoroid", "Ice Meteoroid", false));
}
}

View File

@ -59,4 +59,9 @@ public abstract class Perk implements Listener
{
// When listener has been registered
}
public void unregisteredEvents()
{
// When listener has been registered
}
}

View File

@ -121,6 +121,15 @@ public class PerkZombieBile extends SmashPerk implements IThrown
}
}
@EventHandler
public void death(PlayerDeathEvent event)
{
if (_active.containsKey(event.getEntity()))
{
_active.remove(event.getEntity());
}
}
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{

View File

@ -1,13 +1,8 @@
package nautilus.game.arcade.scoreboard;
import java.util.ArrayList;
import java.util.HashSet;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
@ -16,6 +11,7 @@ import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
@ -27,7 +23,7 @@ public class GameScoreboard
private Objective _sideObjective;
private ArrayList<ScoreboardElement> _elements = new ArrayList<ScoreboardElement>();
private String[] _current = new String[15];
private char[] _chars = "1234567890abcdefghijklmnopqrstuvwxyz".toCharArray();
private String _title;
private int _shineIndex;
@ -246,84 +242,61 @@ public class GameScoreboard
if (_debug) System.out.println();
if (_debug) System.out.println("/////////////////////////");
//Generate Lines
// Generate Lines
ArrayList<String> newLines = new ArrayList<String>();
for (ScoreboardElement elem : _elements)
{
for (String line : elem.GetLines())
{
//Ensure no duplicate lines
while (true)
{
boolean matched = false;
newLines.addAll(elem.GetLines());
}
for (String otherLine : newLines)
int i = 0;
while (true)
{
if (i >= _chars.length)
break;
String str = ChatColor.COLOR_CHAR + "" + _chars[i];
Score score = GetObjectiveSide().getScore(str);
if (newLines.size() <= i)
{
if (score.isScoreSet())
{
ResetScore(str);
}
else
{
break;
}
}
else
{
Team team = GetScoreboard().getTeam(str);
if (team == null)
{
team = GetScoreboard().registerNewTeam(str);
team.addEntry(str);
}
String line = newLines.get(i);
team.setPrefix(line);
if (!score.isScoreSet())
{
if (i == 15)
{
if (line.equals(otherLine))
{
line += ChatColor.RESET;
matched = true;
}
score.setScore(1);
}
if (!matched)
break;
score.setScore(15 - i);
}
newLines.add(line);
}
}
//Find Changes
HashSet<Integer> toAdd = new HashSet<Integer>();
HashSet<Integer> toDelete = new HashSet<Integer>();
for (int i=0 ; i<15 ; i++)
{
//Delete Old Excess Row
if (i >= newLines.size())
{
if (_current[i] != null)
{
if (_debug) System.out.println("Delete: " + i + " [" + _current[i] + "]");
toDelete.add(i);
}
continue;
}
//Update or Add Row
if (_current[i] == null || !_current[i].equals(newLines.get(i)))
{
if (_debug) System.out.println("Update: " + i + " [" + newLines.get(i) + "]");
toDelete.add(i);
toAdd.add(i);
}
}
//Delete Elements - Must happen before Add
for (int i : toDelete)
{
//Remove Old Line at Index
if (_current[i] != null)
{
if (_debug) System.out.println("Deleting: " + i + " [" + _current[i] + "]");
ResetScore(_current[i]);
_current[i] = null;
}
}
//Add Elements
for (int i : toAdd)
{
//Insert New Line
String newLine = newLines.get(i);
GetObjectiveSide().getScore(newLine).setScore(15-i);
_current[i] = newLine;
if (_debug) System.out.println("Setting: " + (15-i) + " [" + newLine + "]");
i++;
}
}