Merge pull request #58 in MIN/mineplex from clans_custom_gear to clans-beta
* commit 'ab73cc2fbed1fe8d2c80eb217ace19da19ad1f11': Fix bug where murders were not properly taking place in certain instances of players wielding weapons or armour as well as in certain claimed areas. Fix bug where BlockToss could be exploited to break into an enemy clan's claimed base. Fixed bug where percent sign was not properly escaped in certain item attributes. Remove debug line from shop.
This commit is contained in:
commit
5347b8a1aa
@ -49,6 +49,7 @@ public class MurderManager extends MiniClientPlugin<WeaklingStatus>
|
|||||||
if (event.GetEvent().getEntity() instanceof Player)
|
if (event.GetEvent().getEntity() instanceof Player)
|
||||||
{
|
{
|
||||||
Player deadPlayer = ((Player) event.GetEvent().getEntity());
|
Player deadPlayer = ((Player) event.GetEvent().getEntity());
|
||||||
|
refreshWeaklingStatus(deadPlayer);
|
||||||
Location location = deadPlayer.getLocation();
|
Location location = deadPlayer.getLocation();
|
||||||
|
|
||||||
CombatComponent combatKiller = event.GetLog().GetKiller();
|
CombatComponent combatKiller = event.GetLog().GetKiller();
|
||||||
@ -136,22 +137,9 @@ public class MurderManager extends MiniClientPlugin<WeaklingStatus>
|
|||||||
|
|
||||||
private boolean canMurderOccur(Player killer, Player dead, Location location)
|
private boolean canMurderOccur(Player killer, Player dead, Location location)
|
||||||
{
|
{
|
||||||
ClanInfo killerClan = _clansManager.getClan(killer);
|
|
||||||
ClanInfo deadClan = _clansManager.getClan(dead);
|
|
||||||
ClanTerritory territory = _clansManager.getClanUtility().getClaim(location);
|
ClanTerritory territory = _clansManager.getClanUtility().getClaim(location);
|
||||||
|
|
||||||
if (territory != null)
|
return (territory == null); // Murder can only occur in unclaimed land
|
||||||
{
|
|
||||||
// Check Borderlands, Fields
|
|
||||||
if (territory.Owner.equalsIgnoreCase("Borderlands") || territory.Owner.equalsIgnoreCase("Fields"))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Check killer/dead territory
|
|
||||||
if ((killerClan != null && territory.Owner.equals(killerClan.getName())) || (deadClan != null && territory.Owner.equals(deadClan.getName())))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshWeaklingStatus(Player player)
|
private void refreshWeaklingStatus(Player player)
|
||||||
@ -161,9 +149,12 @@ public class MurderManager extends MiniClientPlugin<WeaklingStatus>
|
|||||||
int inventorySize = player.getInventory().getSize() + 4; // Add 4 for armor contents
|
int inventorySize = player.getInventory().getSize() + 4; // Add 4 for armor contents
|
||||||
for (int i = 0; i < inventorySize && weakling; i++)
|
for (int i = 0; i < inventorySize && weakling; i++)
|
||||||
{
|
{
|
||||||
if (contains(weapons, player.getInventory().getItem(i)) || contains(armour, player.getInventory().getItem(i)))
|
ItemStack item = player.getInventory().getItem(i);
|
||||||
|
if (contains(weapons, item) || contains(armour, item))
|
||||||
|
{
|
||||||
weakling = false;
|
weakling = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Get(player).setStatus(weakling);
|
Get(player).setStatus(weakling);
|
||||||
}
|
}
|
||||||
@ -179,6 +170,7 @@ public class MurderManager extends MiniClientPlugin<WeaklingStatus>
|
|||||||
if (materials[i].equals(mat))
|
if (materials[i].equals(mat))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@ import java.util.HashSet;
|
|||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||||
|
import mineplex.minecraft.game.classcombat.event.BlockTossEvent;
|
||||||
|
import mineplex.minecraft.game.classcombat.event.BlockTossExpireEvent;
|
||||||
|
import mineplex.minecraft.game.classcombat.event.BlockTossLandEvent;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
@ -27,6 +30,7 @@ import mineplex.game.clans.items.generation.WeightSet;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
@ -74,6 +78,15 @@ public class Gameplay extends MiniPlugin
|
|||||||
_foodDecrease = new WeightSet<Boolean>(new Weight<Boolean>(10, true), new Weight<Boolean>(90, false));
|
_foodDecrease = new WeightSet<Boolean>(new Weight<Boolean>(10, true), new Weight<Boolean>(90, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockToss(BlockTossEvent event)
|
||||||
|
{
|
||||||
|
Location location = event.getLocation();
|
||||||
|
if (_clansManager.getClanUtility().isClaimed(location))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBowShoot(EntityShootBowEvent event)
|
public void onBowShoot(EntityShootBowEvent event)
|
||||||
|
@ -25,6 +25,6 @@ public class LavaAttribute extends PercentReductionAttribute
|
|||||||
@Override
|
@Override
|
||||||
public String getDescription()
|
public String getDescription()
|
||||||
{
|
{
|
||||||
return String.format("Reduces damage from fire and lava by %.1f%.", getReductionPercent() * 100d);
|
return String.format("Reduces damage from fire and lava by %.1f%%.", getReductionPercent() * 100d);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -29,7 +29,7 @@ public class HeavyArrowsAttribute extends ItemAttribute
|
|||||||
@Override
|
@Override
|
||||||
public String getDescription()
|
public String getDescription()
|
||||||
{
|
{
|
||||||
return String.format("Increase knockback by %.2f%", _knockbackPercent);
|
return String.format("Increase knockback by %.2f%%.", _knockbackPercent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,7 +27,7 @@ public class HeavyAttribute extends ItemAttribute
|
|||||||
@Override
|
@Override
|
||||||
public String getDescription()
|
public String getDescription()
|
||||||
{
|
{
|
||||||
return String.format("%.1f% additional knockback.", _knockbackBoost);
|
return String.format("%.1f%% additional knockback.", _knockbackBoost);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,22 +59,4 @@ public class ClansServerShop extends ShopBase<ServerManager>
|
|||||||
{
|
{
|
||||||
getPlugin().getHubManager().GetVisibility().removeHiddenPlayer(player);
|
getPlugin().getHubManager().GetVisibility().removeHiddenPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: REMOVE THIS, JUST FOR DEBUGGING
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
|
||||||
{
|
|
||||||
System.out.println("CALLED");
|
|
||||||
if (event.getPlayer().getName().equalsIgnoreCase("Elinoo")
|
|
||||||
|| event.getPlayer().getName().equalsIgnoreCase("MrTwiggy")
|
|
||||||
|| event.getPlayer().getName().equalsIgnoreCase("GetGrimyWits"))
|
|
||||||
{
|
|
||||||
System.out.println("CALLED2");
|
|
||||||
if (event.getPlayer().isSneaking() && event.getAction() == Action.RIGHT_CLICK_AIR)
|
|
||||||
{
|
|
||||||
System.out.println("CALLED3");
|
|
||||||
this.attemptShopOpen(event.getPlayer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
@ -38,6 +39,8 @@ import mineplex.minecraft.game.classcombat.Skill.SkillCharge;
|
|||||||
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillEvent;
|
import mineplex.minecraft.game.classcombat.Skill.event.SkillEvent;
|
||||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||||
|
import mineplex.minecraft.game.classcombat.event.BlockTossExpireEvent;
|
||||||
|
import mineplex.minecraft.game.classcombat.event.BlockTossLandEvent;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
public class BlockToss extends SkillCharge implements IThrown
|
public class BlockToss extends SkillCharge implements IThrown
|
||||||
@ -305,6 +308,12 @@ public class BlockToss extends SkillCharge implements IThrown
|
|||||||
if (block.getType() != fall.getMaterial())
|
if (block.getType() != fall.getMaterial())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Call and trigger block expiry event
|
||||||
|
BlockTossExpireEvent expireEvent = new BlockTossExpireEvent(block);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(expireEvent);
|
||||||
|
|
||||||
|
if (!expireEvent.isCancelled())
|
||||||
|
{
|
||||||
block.setTypeIdAndData(0, (byte)0, false);
|
block.setTypeIdAndData(0, (byte)0, false);
|
||||||
|
|
||||||
//Block Replace
|
//Block Replace
|
||||||
@ -314,16 +323,37 @@ public class BlockToss extends SkillCharge implements IThrown
|
|||||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
|
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockLand(EntityChangeBlockEvent event)
|
||||||
|
{
|
||||||
|
if (event.getEntity() instanceof FallingBlock)
|
||||||
|
{
|
||||||
|
if (event.getBlock().getType() == Material.AIR) // Falling block is landing and turning block from air to type
|
||||||
|
{
|
||||||
|
BlockTossLandEvent landEvent = new BlockTossLandEvent(event.getBlock());
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(landEvent);
|
||||||
|
|
||||||
|
if (landEvent.isCancelled())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void ItemSpawn(ItemSpawnEvent event)
|
public void ItemSpawn(ItemSpawnEvent event)
|
||||||
{
|
{
|
||||||
int id = event.getEntity().getItemStack().getTypeId();
|
|
||||||
|
|
||||||
for (FallingBlock block : _falling.keySet())
|
for (FallingBlock block : _falling.keySet())
|
||||||
|
{
|
||||||
if (UtilMath.offset(event.getEntity().getLocation(), block.getLocation()) < 1)
|
if (UtilMath.offset(event.getEntity().getLocation(), block.getLocation()) < 1)
|
||||||
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Reset(Player player)
|
public void Reset(Player player)
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package mineplex.minecraft.game.classcombat.event;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class BlockTossEvent extends Event implements Cancellable
|
||||||
|
{
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
public static HandlerList getHandlerList() { return handlers; }
|
||||||
|
public HandlerList getHandlers() { return handlers; }
|
||||||
|
|
||||||
|
private boolean _cancelled;
|
||||||
|
public boolean isCancelled() { return _cancelled; }
|
||||||
|
public void setCancelled(boolean cancelled) { _cancelled = cancelled; }
|
||||||
|
|
||||||
|
private Block _block;
|
||||||
|
public Block getBlock() { return _block; }
|
||||||
|
public Location getLocation() { return _block.getLocation(); }
|
||||||
|
|
||||||
|
public BlockTossEvent(Block block)
|
||||||
|
{
|
||||||
|
_block = block;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package mineplex.minecraft.game.classcombat.event;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
|
public class BlockTossExpireEvent extends BlockTossEvent
|
||||||
|
{
|
||||||
|
public BlockTossExpireEvent(Block block)
|
||||||
|
{
|
||||||
|
super(block);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package mineplex.minecraft.game.classcombat.event;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.FallingBlock;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class BlockTossLandEvent extends BlockTossEvent
|
||||||
|
{
|
||||||
|
|
||||||
|
public BlockTossLandEvent(Block block)
|
||||||
|
{
|
||||||
|
super(block);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user