Fix memory leak in player gear management. Update custom gear display design for title and description to fit CJ's specified design, as well as updating attribute descriptions to match google doc more closely. Fix bug with damage reduction attributes adding instead of reducing damage. Fix bug with parse errors causing defective attribute bugs and console spam with certain custom gear attributes. Fix bug where legend was not being properly displayed for /c map command. Fix bug where chunks could be claimed diagonally to opposing enemy clans. Fix bug with redstone not properly being disabled. Fix bug with attribute effects taking place even when damage events were cancelled, such as in safe zones. Fix bug with dispensers being able to place lava and water blocks. Fix bug where holding a book caused debug chat spam for players in regards to custom damage events.
This commit is contained in:
parent
d2f633f572
commit
0b49d053fe
@ -150,6 +150,10 @@ public class ClansDisplay extends MiniPlugin
|
||||
else
|
||||
for (int i = 0 ; i < local.size() ; i++)
|
||||
UtilPlayer.message(player, local.get(i) + " " + home.get(i));
|
||||
|
||||
// Display legend for map symbols
|
||||
UtilPlayer.message(player, C.xNone + "X: Current, #: Claimed, H: Home");
|
||||
UtilPlayer.message(player, C.xNone + "S: Safe, +: Admin, -: Unclaimed");
|
||||
}
|
||||
|
||||
public LinkedList<String> mLocalMap(Player player, Chunk chunk, boolean local)
|
||||
|
@ -251,7 +251,7 @@ public class ClansGame extends MiniPlugin
|
||||
mimic));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void Damage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.IsCancelled())
|
||||
|
@ -840,28 +840,24 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
if (adjClan == null)
|
||||
continue;
|
||||
|
||||
if (x == 0 || z == 0)
|
||||
if (checkBox(caller.getWorld().getChunkAt(
|
||||
caller.getLocation().getChunk().getX()+x,
|
||||
caller.getLocation().getChunk().getZ()+z), 3))
|
||||
{
|
||||
if (checkBox(caller.getWorld().getChunkAt(
|
||||
caller.getLocation().getChunk().getX()+x,
|
||||
caller.getLocation().getChunk().getZ()+z), 3))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You cannot claim this Territory, it causes a box."));
|
||||
UtilPlayer.message(caller, F.main("Clans", "This means a Territory has all sides claimed."));
|
||||
return;
|
||||
}
|
||||
UtilPlayer.message(caller, F.main("Clans", "You cannot claim this Territory, it causes a box."));
|
||||
UtilPlayer.message(caller, F.main("Clans", "This means a Territory has all sides claimed."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Plugin.getClanUtility().rel(clan, adjClan) == ClanRelation.SELF)
|
||||
{
|
||||
selfAdj = true;
|
||||
}
|
||||
|
||||
else if (Plugin.getClanUtility().rel(clan, adjClan) != ClanRelation.SELF)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You cannot claim Territory next to " +
|
||||
Plugin.getClanUtility().mRel(Plugin.getClanUtility().rel(ownerClan, adjClan), adjClan.getName(), true) + "."));
|
||||
return;
|
||||
}
|
||||
if (Plugin.getClanUtility().rel(clan, adjClan) == ClanRelation.SELF)
|
||||
{
|
||||
selfAdj = true;
|
||||
}
|
||||
else if (Plugin.getClanUtility().rel(clan, adjClan) != ClanRelation.SELF)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You cannot claim Territory next to " +
|
||||
Plugin.getClanUtility().mRel(Plugin.getClanUtility().rel(ownerClan, adjClan), adjClan.getName(), true) + "."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
@ -141,6 +142,28 @@ public class Gameplay extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void RedstoneCancel(BlockPlaceEvent event)
|
||||
{
|
||||
if (event.getBlock().getType().toString().startsWith("REDSTONE"))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place redstone based items."));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void DispenseLiquidCancel(BlockDispenseEvent event)
|
||||
{
|
||||
Material material = event.getItem().getType();
|
||||
|
||||
if (material == Material.LAVA_BUCKET || material == Material.LAVA
|
||||
|| material == Material.WATER_BUCKET || material == Material.WATER)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void WebBreak(BlockDamageEvent event)
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ import mineplex.game.clans.items.attributes.AttributeContainer;
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
@ -25,6 +26,9 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
public class CustomItem
|
||||
{
|
||||
|
||||
private static final ChatColor TITLE_COLOR = ChatColor.GOLD; // Chat color used for item display name
|
||||
private static final ChatColor ATTRIBUTE_COLOR = ChatColor.WHITE; // Chat color used for attribute descriptions
|
||||
|
||||
private AttributeContainer _attributes;
|
||||
public AttributeContainer getAttributes() { return _attributes; }
|
||||
|
||||
@ -53,7 +57,7 @@ public class CustomItem
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return _attributes.formatItemName(_displayName);
|
||||
return ChatColor.RESET.toString() + TITLE_COLOR + _attributes.formatItemName(_displayName);
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
@ -63,8 +67,6 @@ public class CustomItem
|
||||
|
||||
public List<String> getLore()
|
||||
{
|
||||
String serialization = GearManager.getItemSerialization(this);
|
||||
|
||||
List<String> lore = new ArrayList<String>();
|
||||
|
||||
if (getDescription() != null)
|
||||
@ -75,18 +77,13 @@ public class CustomItem
|
||||
// Display attribute descriptions and stats in lore
|
||||
for (ItemAttribute attribute : _attributes.getAttributes())
|
||||
{
|
||||
String attributeLine = attribute.getDisplayName() + " - " + attribute.getDescription();
|
||||
String attributeLine = ATTRIBUTE_COLOR + "-" + attribute.getDescription();
|
||||
lore.add(attributeLine);
|
||||
}
|
||||
|
||||
// Tack on serialized JSON encoded line for utility purposes. (Not seen by user)
|
||||
List<String> serializedLines = new ArrayList<String>();
|
||||
String[] seri = serialization.split("\n");
|
||||
for (String line : seri)
|
||||
{
|
||||
serializedLines.add(line);
|
||||
}
|
||||
lore.addAll(serializedLines);
|
||||
// Add encoded JSON form of this item, not seen by user.
|
||||
String serialization = GearManager.getItemSerialization(this);
|
||||
lore.add(serialization);
|
||||
|
||||
return lore;
|
||||
}
|
||||
|
@ -181,7 +181,14 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
{
|
||||
for (PlayerGear gear : _playerGears.values())
|
||||
{
|
||||
gear.update();
|
||||
if (gear.isOnline())
|
||||
{
|
||||
gear.update();
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerGears.remove(gear.getPlayerName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
@ -69,9 +70,11 @@ public class ItemListener implements Listener
|
||||
* Handle the trigger of custom gear related effects and abilities.
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerAttack(CustomDamageEvent event)
|
||||
{
|
||||
if (event.IsCancelled()) return; // Checks for Pre-Cancelled event and stops
|
||||
|
||||
Player damager = event.GetDamagerPlayer(false); // For non-ranged attacks
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
Projectile projectile = event.GetProjectile();
|
||||
|
@ -23,6 +23,7 @@ import org.bukkit.inventory.PlayerInventory;
|
||||
public class PlayerGear
|
||||
{
|
||||
private String _playerName; // Name of player who owns the gear
|
||||
public String getPlayerName() { return _playerName; }
|
||||
|
||||
// Cached custom item information for player's gear
|
||||
private CustomItem weapon;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.game.clans.items.attributes.armor;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
@ -11,7 +12,7 @@ import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
public class ConqueringArmorAttribute extends FlatReductionAttribute
|
||||
{
|
||||
private static ValueDistribution reductionGen = generateDistribution(1.0d, 4.0d);
|
||||
private static ReductionConfig config = new ReductionConfig(EntityType.values());
|
||||
private static ReductionConfig config = new ReductionConfig();
|
||||
|
||||
public ConqueringArmorAttribute()
|
||||
{
|
||||
@ -27,6 +28,12 @@ public class ConqueringArmorAttribute extends FlatReductionAttribute
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Reduce incoming damage from mobs and bosses by %.2f half-hearts.", getFlatReduction());
|
||||
return String.format("-%.1f damage taken from mobs & bosses.", getFlatReduction());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reducesDamage(DamageCause cause, Entity attacker)
|
||||
{
|
||||
return attacker != null; // Reduces damage from all entities
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,6 @@ public class LavaAttribute extends PercentReductionAttribute
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Reduce fire-related damage by %.2f percent.", getReductionPercent());
|
||||
return String.format("Reduces damage from fire and lava by %.1f%.", getReductionPercent() * 100d);
|
||||
}
|
||||
}
|
@ -25,6 +25,6 @@ public class PaddedAttribute extends FlatReductionAttribute
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Reduce fall damage by %.2f half-hearts.", getFlatReduction());
|
||||
return String.format("-%.1f damage taken from falls.", getFlatReduction());
|
||||
}
|
||||
}
|
||||
|
@ -31,11 +31,11 @@ public abstract class ReductionAttribute extends ItemAttribute
|
||||
DamageCause cause = event.GetCause();
|
||||
Entity attacker = event.GetDamagerEntity(true);
|
||||
|
||||
if (_config.reducesDamage(cause, attacker))
|
||||
if (reducesDamage(cause, attacker))
|
||||
{
|
||||
double damage = event.GetDamage();
|
||||
double reduction = getDamageReduction(damage);
|
||||
event.AddMod("Reduction Armor", reduction);
|
||||
event.AddMod("Reduction Armor", -reduction);
|
||||
System.out.println("Reduced damage by " + reduction);
|
||||
}
|
||||
else
|
||||
@ -44,5 +44,10 @@ public abstract class ReductionAttribute extends ItemAttribute
|
||||
}
|
||||
}
|
||||
|
||||
public boolean reducesDamage(DamageCause cause, Entity attacker)
|
||||
{
|
||||
return _config.reducesDamage(cause, attacker);
|
||||
}
|
||||
|
||||
public abstract double getDamageReduction(double originalDamage);
|
||||
}
|
||||
|
@ -24,6 +24,6 @@ public class ReinforcedAttribute extends FlatReductionAttribute
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Reduce incoming melee damage by %.2f half-hearts.", getFlatReduction());
|
||||
return String.format("-%.1f damage taken from melee.", getFlatReduction());
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,6 @@ public class SlantedAttribute extends FlatReductionAttribute
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Reduce arrow damage by %.2f half-hearts.", getFlatReduction());
|
||||
return String.format("-%.1f damage taken from projectiles.", getFlatReduction());
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class ConqueringAttribute extends DamageAttribute
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Deal an extra %.2f hearts of damage to mobs.", getBonusDamage());
|
||||
return String.format("%.2f bonus damage against mobs & bosses.", getBonusDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,13 +22,13 @@ public class FlamingAttribute extends AttackAttribute
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return "Flaming"; // TODO: Fill in name
|
||||
return "Flaming";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Enemies catch fire for %d ticks every %d attacks.", _fireDuration, getAttackLimit());
|
||||
return String.format("Every %d attacks gives Fire for %.1f seconds.", getAttackLimit(), (_fireDuration / 20d));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,7 +36,7 @@ public class HasteAttribute extends AttackAttribute
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Gain speed %s for %d ticks every %d attacks.", amplifierToRoman(_speedAmount), _speedDuration, getAttackLimit());
|
||||
return String.format("Every %d attacks gives you Speed %s for %.1f seconds.", getAttackLimit(), amplifierToRoman(_speedAmount), (_speedDuration / 20f));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,26 +3,37 @@ package mineplex.game.clans.items.attributes.weapon;
|
||||
import mineplex.game.clans.items.attributes.AttributeType;
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class HeavyAttribute extends ItemAttribute
|
||||
{
|
||||
// TODO: Replace with your generators
|
||||
private static ValueDistribution healGen = generateDistribution(4, 12); // Value generator for heal amount
|
||||
private static ValueDistribution knockbackGen = generateDistribution(25, 75); // Value generator for knockback % boost.
|
||||
|
||||
private int _healPercent;
|
||||
private double _knockbackBoost;
|
||||
|
||||
public HeavyAttribute()
|
||||
{
|
||||
super(AttributeType.PREFIX);
|
||||
|
||||
_healPercent = healGen.generateIntValue();
|
||||
_knockbackBoost = knockbackGen.generateValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return ""; // TODO: Fill in name
|
||||
return "Heavy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("%.1f% additional knockback.", _knockbackBoost);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onAttack(CustomDamageEvent event)
|
||||
{
|
||||
double knockback = (_knockbackBoost / 100d) * event.getKnockbackValue();
|
||||
event.AddKnockback("Heavy Attribute", knockback);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class JaggedAttribute extends AttackAttribute
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Temporarily halt enemies every %d attacks.", getAttackLimit());
|
||||
return String.format("Every %d attacks mini-stuns enemies.", getAttackLimit());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,7 +24,7 @@ public class SharpAttribute extends DamageAttribute
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Deal an extra %.2f damage.", getBonusDamage());
|
||||
return String.format("%.2f bonus damage.", getBonusDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,7 +30,7 @@ public class VampiricAttribute extends ItemAttribute
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Heal yourself for %d percentage of damage dealt to enemy players.", _healPercent);
|
||||
return String.format("Heal yourself for %d% of damage dealt.", _healPercent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,23 +0,0 @@
|
||||
package mineplex.hub.server.ui.button;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.hub.server.ui.ServerGameMenu;
|
||||
|
||||
public class SelectBHButton implements IButton
|
||||
{
|
||||
private ServerGameMenu _menu;
|
||||
|
||||
public SelectBHButton(ServerGameMenu menu)
|
||||
{
|
||||
_menu = menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_menu.OpenBH(player);
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package mineplex.hub.server.ui.button;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.hub.server.ui.ServerGameMenu;
|
||||
|
||||
public class SelectMSButton implements IButton
|
||||
{
|
||||
private ServerGameMenu _menu;
|
||||
|
||||
public SelectMSButton(ServerGameMenu menu)
|
||||
{
|
||||
_menu = menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_menu.openMS(player);
|
||||
}
|
||||
}
|
@ -248,7 +248,9 @@ public class DamageManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
DisplayDamage(event);
|
||||
// TODO: What is this required for? Players with books in regular games are spammed. Is it meant for debugging?
|
||||
// TODO: Temporarily commenting out
|
||||
//DisplayDamage(event);
|
||||
}
|
||||
|
||||
private void Damage(CustomDamageEvent event)
|
||||
|
Loading…
Reference in New Issue
Block a user