All Damage events can now increase Artifact experience. Added in

canPlaceShopSignOnBlock(Location) to API. Limited chicken spawn cap to
20 in a small region.
dev
sigonasr2 9 years ago
parent 94d607e53c
commit 4d04a39c85
  1. BIN
      TwosideKeeper.jar
  2. 2
      src/plugin.yml
  3. 21
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java
  4. 4
      src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java
  5. 9
      src/sig/plugin/TwosideKeeper/NewCombat.java
  6. 16
      src/sig/plugin/TwosideKeeper/TwosideKeeper.java
  7. 3
      src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java

Binary file not shown.

@ -1,6 +1,6 @@
name: TwosideKeeper
main: sig.plugin.TwosideKeeper.TwosideKeeper
version: 3.7.3-alpha5
version: 3.7.3-alpha6
commands:
money:
description: Tells the player the amount of money they are holding.

@ -2649,16 +2649,16 @@ public class GenericFunctions {
@Deprecated
public static void DealDamageToMob(double dmg, LivingEntity target, LivingEntity damager, boolean truedmg) {
DealDamageToMob(dmg,target,damager);
DealDamageToMob(dmg,target,damager,null);
}
public static void DealDamageToMob(double dmg, LivingEntity target, Entity damager) {
DealDamageToMob(dmg,target,NewCombat.getDamagerEntity(damager));
DealDamageToMob(dmg,target,NewCombat.getDamagerEntity(damager),null);
}
public static void DealDamageToMob(double dmg, LivingEntity target, LivingEntity damager) {
public static void DealDamageToMob(double dmg, LivingEntity target, LivingEntity damager, ItemStack artifact) {
if (damager!=null && (target instanceof Monster)) {
Monster m = (Monster)target;
m.setTarget(damager);
@ -2675,7 +2675,15 @@ public class GenericFunctions {
TwosideKeeper.log(GenericFunctions.GetEntityDisplayName(damager)+"->"+
GenericFunctions.GetEntityDisplayName(target)+ChatColor.WHITE+": Damage dealt was "+dmg,2);
double oldhp=((LivingEntity)target).getHealth();
GenericFunctions.subtractHealth(target, damager, dmg);
GenericFunctions.subtractHealth(target, damager, dmg, artifact);
if (artifact!=null &&
GenericFunctions.isArtifactEquip(artifact) &&
(damager instanceof Player)) {
Player p = (Player)damager;
double ratio = 1.0-NewCombat.CalculateDamageReduction(1,target,p);
AwakenedArtifact.addPotentialEXP(damager.getEquipment().getItemInMainHand(), (int)((ratio*20)+5), p);
NewCombat.increaseArtifactArmorXP(p,(int)(ratio*10)+1);
}
TwosideKeeper.log(ChatColor.BLUE+" "+oldhp+"->"+((LivingEntity)target).getHealth()+" HP",3);
}
@ -2784,8 +2792,11 @@ public class GenericFunctions {
public static double getAbilityValue(ArtifactAbility ab, ItemStack weapon) {
return ArtifactAbility.calculateValue(ab, weapon.getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ab, weapon));
}
public static void subtractHealth(LivingEntity entity, LivingEntity damager, double dmg) {
subtractHealth(entity,damager,dmg,null);
}
public static void subtractHealth(LivingEntity entity, LivingEntity damager, double dmg, ItemStack artifact) {
if (damager instanceof Player) {
TwosideKeeper.log("Damage goes from "+dmg+"->"+(dmg+TwosideKeeper.CUSTOM_DAMAGE_IDENTIFIER),5);
entity.damage(dmg+TwosideKeeper.CUSTOM_DAMAGE_IDENTIFIER,damager);

@ -814,4 +814,8 @@ public class WorldShop {
return true;
}
}
public static boolean canPlaceShopSignOnBlock(Location block_loc) {
return (!shopSignExists(block_loc) && GenericFunctions.isDumpableContainer(block_loc.getBlock().getType()));
}
}

@ -346,7 +346,7 @@ public class NewCombat {
Monster mon = (Monster)finallist.get(i);
double finaldmg = CalculateDamageReduction(GenericFunctions.getAbilityValue(ArtifactAbility.ERUPTION, p.getEquipment().getItemInMainHand()),mon,null);
addToPlayerLogger(p,ChatColor.BLUE+"Eruption",finaldmg);
GenericFunctions.DealDamageToMob(finaldmg, mon, p);
GenericFunctions.DealDamageToMob(finaldmg, mon, p, p.getEquipment().getItemInMainHand());
mon.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,20,15));
//Attempt to dig out the blocks below.
for (int x=-1;x<2;x++) {
@ -904,7 +904,8 @@ public class NewCombat {
for (int i=0;i<hitlist.size();i++) {
if (!hitlist.get(i).equals(target)) {
hitlist.get(i).damage(dmg);
//hitlist.get(i).damage(dmg);
GenericFunctions.DealDamageToMob(dmg, hitlist.get(i), shooter, weapon);
};
if (applyDeathMark) {
GenericFunctions.ApplyDeathMark(hitlist.get(i));
@ -929,7 +930,7 @@ public class NewCombat {
}
}
private static void increaseArtifactArmorXP(Player p, int exp) {
public static void increaseArtifactArmorXP(Player p, int exp) {
for (int i=0;i<p.getEquipment().getArmorContents().length;i++) {
if (GenericFunctions.isArtifactEquip(p.getEquipment().getArmorContents()[i]) &&
GenericFunctions.isArtifactArmor(p.getEquipment().getArmorContents()[i])) {
@ -965,7 +966,7 @@ public class NewCombat {
return list;
}
static List<LivingEntity> trimNonLivingEntities(List<Entity> entitylist) {
public static List<LivingEntity> trimNonLivingEntities(List<Entity> entitylist) {
List<LivingEntity> livinglist = new ArrayList<LivingEntity>();
for (int i=0;i<entitylist.size();i++) {
if ((entitylist.get(i) instanceof LivingEntity) && !(entitylist.get(i) instanceof Player)) {

@ -113,6 +113,7 @@ import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerChatTabCompleteEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerEggThrowEvent;
import org.bukkit.event.player.PlayerExpChangeEvent;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerFishEvent.State;
@ -2268,7 +2269,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
WorldShop shop = TwosideShops.LoadWorldShopData(shopID);
Chest c = (Chest)chest.getState();
shop.UpdateAmount(GenericFunctions.CountItems(c.getInventory(), shop.GetItem()));
TwosideShops.UpdateSign(shop, shop.getID(),s,false);
TwosideShops.UpdateSign(shop, shop.getID(),s,shop.isPurchaseShopSign(s));
TwosideShops.SaveWorldShopData(shop);
Location newloc = ev.getClickedBlock().getLocation().add(-ev.getBlockFace().getModX()+0.5, -ev.getBlockFace().getModY()+1.5, -ev.getBlockFace().getModZ()+0.5);
@ -2355,7 +2356,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
WorldShop shop = TwosideShops.LoadWorldShopData(shopID);
Chest c = (Chest)chest.getState();
shop.UpdateAmount(GenericFunctions.CountItems(c.getInventory(), shop.GetItem()));
TwosideShops.UpdateSign(shop, shop.getID(),s,false);
TwosideShops.UpdateSign(shop, shop.getID(),s,shop.isPurchaseShopSign(s));
TwosideShops.SaveWorldShopData(shop);
Location newloc = ev.getClickedBlock().getLocation().add(-ev.getBlockFace().getModX()+0.5, -ev.getBlockFace().getModY()+1.5, -ev.getBlockFace().getModZ()+0.5);
WorldShop.spawnShopItem(ev,newloc,shop);
@ -3431,6 +3432,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void MonsterSpawnEvent(CreatureSpawnEvent ev) {
if ((ev.getSpawnReason().equals(SpawnReason.DISPENSE_EGG) ||
ev.getSpawnReason().equals(SpawnReason.EGG)) &&
NewCombat.trimNonLivingEntities(ev.getEntity().getNearbyEntities(8, 8, 8)).size()>20) {
ev.setCancelled(true);
log("Denied chicken spawn.",4);
}
if ((ev.getSpawnReason().equals(SpawnReason.NATURAL) ||
ev.getSpawnReason().equals(SpawnReason.SPAWNER_EGG) ||
ev.getSpawnReason().equals(SpawnReason.REINFORCEMENTS) ||
@ -4277,14 +4285,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
log("Dealing "+dmgdealt+" damage. Player is "+Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]).getName(),4);
double reduceddmg = CalculateDamageReduction(dmgdealt,affected.get(i),null);
DamageLogger.AddNewCalculation(Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]), ChatColor.GREEN+"Earth Wave", dmgdealt, reduceddmg);
GenericFunctions.DealDamageToMob(reduceddmg, affected.get(i), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]));
GenericFunctions.DealDamageToMob(reduceddmg, affected.get(i), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]).getEquipment().getItemInMainHand());
} else
if (ev.getEntity().getCustomName().contains("LD ")) {
double dmgdealt=Double.parseDouble(ev.getEntity().getCustomName().split(" ")[1]);
log("Dealing "+dmgdealt+" damage. Player is "+Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]).getName(),4);
double reduceddmg = CalculateDamageReduction(dmgdealt,affected.get(i),null);
DamageLogger.AddNewCalculation(Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]), ChatColor.GREEN+"Line Drive", dmgdealt, reduceddmg);
GenericFunctions.DealDamageToMob(reduceddmg, affected.get(i), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]));
GenericFunctions.DealDamageToMob(reduceddmg, affected.get(i), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]).getEquipment().getItemInMainHand());
((Monster)affected.get(i)).addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,2,100));}
}
} else {

@ -185,6 +185,9 @@ public final class TwosideKeeperAPI {
public static void removeWorldShopDisplayItem(Sign s) {
WorldShop.removeShopItem(s);
}
public static boolean canPlaceShopSignOnBlock(Location block_loc) {
return WorldShop.canPlaceShopSignOnBlock(block_loc);
}
//Recycling Center COMMANDS.
public static boolean isRecyclingCenter(Block b) {

Loading…
Cancel
Save