Add in Powered Mobs.

dev
sigonasr2 11 years ago
parent ca45f2a673
commit 9688c1b34f
  1. 44
      BankEconomyMod/src/me/kaZep/Base/Main.java
  2. 46
      BankEconomyMod/src/me/kaZep/Base/PlayerListener.java
  3. 12
      BankEconomyMod/src/me/kaZep/Base/PoweredMob.java
  4. 9
      BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java

@ -192,6 +192,7 @@ public class Main extends JavaPlugin
public List<PlayerData> playerdata_list = null;
public List<InvisibilityData> ninjavisible_list = null;
public List<ReviveInventory> revive_inventory_list = null;
public List<PoweredMob> powered_mob_list = null;
public List<Chunk> chunk_queue_list = null;
public static List<RecyclingCenterNode> recycling_center_list = null;
public static List<BonusEnchantment> bonus_enchantment_list = null;
@ -320,6 +321,7 @@ public class Main extends JavaPlugin
revive_inventory_list = new ArrayList<ReviveInventory>();
chunk_queue_list = new ArrayList<Chunk>();
bonus_enchantment_list = new ArrayList<BonusEnchantment>();
powered_mob_list = new ArrayList<PoweredMob>();
recycling_center_list = new ArrayList<RecyclingCenterNode>();
@ -1481,7 +1483,7 @@ public void runTick() {
}
if (BOSS_DEFEAT>0) {
if (BOSS_DEFEAT%4==0) {
Bukkit.getWorld("world").playEffect(BOSS_DEFEAT_LOC.add(Math.random()*5-Math.random()*5, BOSS_DEFEAT/20, Math.random()*5-Math.random()*5), Effect.SMOKE, 0);
Bukkit.getWorld("world").playEffect(new Location(BOSS_DEFEAT_LOC.getWorld(),BOSS_DEFEAT_LOC.getX()+Math.random()*5-Math.random()*5, BOSS_DEFEAT_LOC.getY()+BOSS_DEFEAT/20, BOSS_DEFEAT_LOC.getZ()+Math.random()*5-Math.random()*5), Effect.SMOKE, 0);
}
if (BOSS_DEFEAT==1) {
Bukkit.getWorld("world").playEffect(BOSS_DEFEAT_LOC, Effect.ZOMBIE_DESTROY_DOOR, 0);
@ -1782,6 +1784,12 @@ public void runTick() {
}
}
if (Main.SERVER_TICK_TIME%20==0) {
for (int j=0;j<powered_mob_list.size();j++) {
if (powered_mob_list.get(j).power_time+1200<Main.SERVER_TICK_TIME) {
powered_mob_list.remove(j);
j--;
}
}
for (int d=0;d<chunk_queue_list.size();d++) {
if (chunk_queue_list.get(d)==null || !chunk_queue_list.get(d).isLoaded()) {
chunk_queue_list.remove(0);
@ -2025,7 +2033,7 @@ public void runTick() {
//List<Entity> nearby2 = p.getNearbyEntities(10, 6, 10);
for (int i=0;i<nearby.size();i++) {
//EntityType allowedtypes[] = {EntityType.BAT,EntityType.BLAZE,EntityType.CAVE_SPIDER,EntityType.ENDERMAN,EntityType.GHAST,EntityType.MAGMA_CUBE,EntityType.PIG_ZOMBIE,EntityType.SILVERFISH,EntityType.SLIME,EntityType.SPIDER,EntityType.ZOMBIE,EntityType.SKELETON,EntityType.CREEPER};
boolean contains=nearby.get(i) instanceof Monster;
boolean contains=nearby.get(i) instanceof LivingEntity;
if (contains) {
LivingEntity l = (LivingEntity)nearby.get(i);
if (l.getCustomName()!=null && l.hasLineOfSight(p)) {
@ -2048,6 +2056,35 @@ public void runTick() {
Location nearestwolf = null;
int minions=0;
for (int i=0;i<nearby.size();i++) {
boolean contains_mob=false;
for (int j=0;j<powered_mob_list.size();j++) {
if (powered_mob_list.get(j).id.equals(nearby.get(i).getUniqueId())) {
contains_mob=true;
//Play particley effects.
nearby.get(i).getWorld().playEffect(nearby.get(i).getLocation(), Effect.BLAZE_SHOOT, 0);
for (int z=0;z<10;z++) {
final Entity mob = nearby.get(i);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
mob.getWorld().playEffect(new Location(mob.getWorld(), mob.getLocation().getX()+(Math.random()*1-Math.random()*1), mob.getLocation().getY()+(Math.random()*1-Math.random()*1), mob.getLocation().getZ()+(Math.random()*1-Math.random()*1)), Effect.MOBSPAWNER_FLAMES, 0);
}
},(int)(Math.random()*30));
}
break;
}
}
if (nearby.get(i).getType()==EntityType.SKELETON ||
nearby.get(i).getType()==EntityType.ZOMBIE ||
nearby.get(i).getType()==EntityType.SPIDER) {
LivingEntity l = (LivingEntity)nearby.get(i);
if (l.getKiller()!=null && Math.random()<=0.5/l.getNearbyEntities(10, 10, 10).size()) {
if (!contains_mob) {
powered_mob_list.add(new PoweredMob(l.getUniqueId(), Main.SERVER_TICK_TIME));
l.getWorld().playSound(l.getLocation(), Sound.SPIDER_DEATH, 0.4f, 0.04f);
}
}
}
if (nearby.get(i).getType()==EntityType.ENDERMAN) {
Creature l = (Creature)nearby.get(i);
if (l.getCustomName()!=null && l.getCustomName().equalsIgnoreCase(ChatColor.RED+"Lightning Mage") && l.getTarget()!=null) {
@ -3433,6 +3470,7 @@ public void checkJukeboxes() {
if (((Jukebox)(jukeboxlist.get(i).getJukebox().getState())).getPlaying()==Material.AIR) {
jukeboxlist.remove(i);
i--;
break;
} else {
//We are playing something still.
jukeboxlist.get(i).updateClosestPlayer();
@ -3455,6 +3493,7 @@ public void checkJukeboxes() {
if (!jukeboxlist.get(i).Restart()) {
jukeboxlist.remove(i);
i--;
break;
} else {
//Bukkit.getPlayer("sigonasr2").sendMessage("Restarted Jukebox "+i+" Properties: "+((Jukebox)(jukeboxlist.get(i).getJukebox().getState())).getPlaying()+","+((Jukebox)(jukeboxlist.get(i).getJukebox().getState())).isPlaying());
}
@ -3464,6 +3503,7 @@ public void checkJukeboxes() {
} else {
jukeboxlist.remove(i);
i--;
break;
}
//Bukkit.getPlayer("sigonasr2").sendMessage("Jukebox "+i+" Properties: "+((Jukebox)(jukeboxlist.get(i).getJukebox().getState())).getPlaying()+","+((Jukebox)(jukeboxlist.get(i).getJukebox().getState())).isPlaying());
}

@ -9400,6 +9400,27 @@ implements Listener
final LivingEntity l = (LivingEntity)e.getEntity();
if (e.getDamager() instanceof LivingEntity) {
LivingEntity l2 = (LivingEntity)e.getDamager();
for (int i=0;i<this.plugin.powered_mob_list.size();i++) {
if (this.plugin.powered_mob_list.get(i).id.equals(l2.getUniqueId())) {
//This mob will damage you if you are not blocking.
if (l instanceof Player) {
Player p = (Player)l;
if (!p.isBlocking()) {
if (p.getHealth()-e.getDamage()<0) {
p.setHealth(0);
} else {
p.setHealth(p.getHealth()-e.getDamage());
}
Main.playFirework(p.getLocation());
Main.playFirework(p.getLocation());
Main.playFirework(p.getLocation());
}
}
this.plugin.powered_mob_list.remove(i);
i--;
break;
}
}
if (l2.getCustomName()!=null && l2.getCustomName().contains(ChatColor.RED+"Powersurge Zombie")) {
int dmgamt = 0; //How much the bonus damage rating to do.
double dmgamt1=0,dmgamt2=0,dmgamt3=0,dmgamt4=0;
@ -15858,40 +15879,40 @@ implements Listener
public int getSongDuration(Material record) {
int padding=20;
if (record==Material.RECORD_3) {
return 345/2+5+padding;
return 345+5+padding;
} else
if (record==Material.RECORD_4) {
return 185/2+5+padding;
return 185+5+padding;
} else
if (record==Material.RECORD_5) {
return 174/2+5+padding;
return 174+5+padding;
} else
if (record==Material.RECORD_6) {
return 197/2+5+padding;
return 197+5+padding;
} else
if (record==Material.RECORD_7) {
return 96/2+5+padding;
return 96+5+padding;
} else
if (record==Material.RECORD_8) {
return 150/2+5+padding;
return 150+5+padding;
} else
if (record==Material.RECORD_9) {
return 188/2+5+padding;
return 188+5+padding;
} else
if (record==Material.RECORD_10) {
return 251/2+5+padding;
return 251+5+padding;
} else
if (record==Material.RECORD_11) {
return 71/2+5+padding;
return 71+5+padding;
} else
if (record==Material.RECORD_12) {
return 238/2+5+padding;
return 238+5+padding;
} else
if (record==Material.GOLD_RECORD) {
return 178/2+5+padding;
return 178+5+padding;
} else
if (record==Material.GREEN_RECORD) {
return 185/2+5+padding;
return 185+5+padding;
} else
return 0;
}
@ -15900,6 +15921,7 @@ implements Listener
public void onPlayerChat(PlayerChatEvent e) {
//Check if they are withdrawing or depositing money.
DecimalFormat df = new DecimalFormat("#0.00");
//e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.SPIDER_DEATH, 5.0f, 0.04f);
if (this.plugin.getPlayerData(e.getPlayer()).is_renaming_item) {
boolean found=false;
for (int i=0;i<e.getPlayer().getInventory().getContents().length;i++) {

@ -0,0 +1,12 @@
package me.kaZep.Base;
import java.util.UUID;
public class PoweredMob {
UUID id;
long power_time;
public PoweredMob(UUID id, long power_time) {
this.id=id;
this.power_time=power_time;
}
}

@ -560,10 +560,15 @@ public String convertToItemName(String val) {
"- Reloads config and accounts.");
}
} else
if (cmd.getName().toLowerCase().equalsIgnoreCase("rename") && args.length==1) {
if (cmd.getName().toLowerCase().equalsIgnoreCase("rename") && args.length>=1) {
if (p.getItemInHand().getType()==Material.NAME_TAG) {
ItemMeta meta = p.getItemInHand().getItemMeta();
meta.setDisplayName(ChatColor.RESET+""+args[0]);
if (meta.getDisplayName()==null) {
meta.setDisplayName(ChatColor.RESET+"");
}
for (int i=0;i<args.length;i++) {
meta.setDisplayName(meta.getDisplayName()+" "+args[i]);
}
p.getItemInHand().setItemMeta(meta);
p.sendMessage("Changed name tag's title to "+p.getItemInHand().getItemMeta().getDisplayName()+".");
}

Loading…
Cancel
Save