->Fixed explosion damage to not scale infinitely bsaed on distance.

->Fixed explosion damage calculation.
->Modified Elite Zombie targeting algorithm to follow proper detection
rules like regular monsters.
->Fixed a bug that never moved an Elite Zombie's spawn when spawn
camping occurred.
->Fixed players from getting kicked from the server on death.
->Tipper Arrows properly display their custom effects when linked now.
->All custom items that used Luck of the Sea just for glowing purposes
now hide the enchantment.
->Enchantments on vials properly display now.
->Added CustomPotion class to handle random generation of vials.
->Added setItemTier(),isUpgradeShard(),getUpgradeShardTier(), and
setUpgradeShardTier() to API.
This commit is contained in:
sigonasr2 2016-08-22 22:20:18 -05:00
parent 645c34a330
commit 698da2eb25
12 changed files with 288 additions and 63 deletions

Binary file not shown.

View File

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

View File

@ -995,9 +995,11 @@ public class CustomDamage {
if (p!=null) { if (p!=null) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.iframetime=0; pd.iframetime=0;
p.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING,1,1), true);
p.removePotionEffect(PotionEffectType.GLOWING); p.removePotionEffect(PotionEffectType.GLOWING);
int level = GenericFunctions.getPotionEffectLevel(PotionEffectType.NIGHT_VISION, p); int level = GenericFunctions.getPotionEffectLevel(PotionEffectType.NIGHT_VISION, p);
if (level==64) { if (level==64) {
p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION,1,1), true);
p.removePotionEffect(PotionEffectType.NIGHT_VISION); p.removePotionEffect(PotionEffectType.NIGHT_VISION);
} }
} }

View File

@ -311,12 +311,14 @@ public class EliteMonster {
} }
private void retargetInAir() { private void retargetInAir() {
if (Math.random()<=0.02) { if (Math.random()<=0.08 ) {
Player p = ChooseRandomTarget(); Player p = ChooseRandomTarget();
//p.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,20*5,-31)); //p.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,20*5,-31));
p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,20*5,-1)); p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,20*5,-1));
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,20*1,7)); p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,20*1,7));
m.setTarget(p); if (Math.random()<=0.25) {
m.setTarget(p);
}
p.setFlying(false); p.setFlying(false);
p.setVelocity(new Vector(0,-1,0)); p.setVelocity(new Vector(0,-1,0));
p.removePotionEffect(PotionEffectType.LEVITATION); p.removePotionEffect(PotionEffectType.LEVITATION);

View File

@ -36,6 +36,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.inventory.meta.PotionMeta;
@ -3126,6 +3127,55 @@ public class GenericFunctions {
} }
UpdateOldRangerPieces(item); UpdateOldRangerPieces(item);
UpdateArtifactDust(item); UpdateArtifactDust(item);
UpdateVials(item);
UpdateHuntersCompass(item);
UpdateUpgradeShard(item);
return item;
}
private static void UpdateHuntersCompass(ItemStack item) {
if (item.getType()==Material.COMPASS &&
item.containsEnchantment(Enchantment.LUCK)) {
item.setItemMeta(TwosideKeeper.HUNTERS_COMPASS.getItemStack().getItemMeta());
}
}
private static void UpdateUpgradeShard(ItemStack item) {
if (isUpgradeShard(item)) {
item.setItemMeta(TwosideKeeper.UPGRADE_SHARD.getItemStack().getItemMeta());
getUpgradeShardTier(item); //This forces the tier to appear.
}
}
private static void UpdateVials(ItemStack item) {
if (item.getType()==Material.POTION) {
if (item.getItemMeta().hasLore() &&
item.getItemMeta().getLore().contains("A fantastic potion, it comes straight")) {
//This is a special potion. Attempt to update it.
boolean newpotion=false;
List<String> lore = item.getItemMeta().getLore();
for (int i=0;i<lore.size();i++) {
if (lore.get(i).contains(ChatColor.GRAY+"")) {
newpotion=true;
break;
}
}
if (!newpotion) {
item = AddCustomPotionTag(item);
}
}
}
}
private static ItemStack AddCustomPotionTag(ItemStack item) {
List<String> lore = item.getItemMeta().getLore();
PotionMeta pm = (PotionMeta)item.getItemMeta();
for (int i=0;i<pm.getCustomEffects().size();i++) {
lore.add(0,ChatColor.GRAY+UserFriendlyPotionEffectTypeName(pm.getCustomEffects().get(i).getType())+" "+WorldShop.toRomanNumeral(pm.getCustomEffects().get(i).getAmplifier()+1)+" ("+WorldShop.toReadableDuration(pm.getCustomEffects().get(i).getDuration())+")");
}
pm.setLore(lore);
pm.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
item.setItemMeta(pm);
return item; return item;
} }
@ -3250,11 +3300,13 @@ public class GenericFunctions {
TwosideKeeper.log("In here", 5); TwosideKeeper.log("In here", 5);
//We cleared the non-living entities, deal damage to the rest. //We cleared the non-living entities, deal damage to the rest.
for (int i=0;i<nearbyentities.size();i++) { for (int i=0;i<nearbyentities.size();i++) {
double damage_mult = 2.0d/(l.distance(nearbyentities.get(i).getLocation())+1.0); //double damage_mult = 2.0d/(l.distance(nearbyentities.get(i).getLocation())+1.0);
TwosideKeeper.log("dmg mult is "+damage_mult,5); double dmg = basedmg * Math.max(0d, 1 - l.distanceSquared(nearbyentities.get(i).getLocation())/range);
double damage_mult=1.0d;
damage_mult*=TwosideKeeper.EXPLOSION_DMG_MULT; damage_mult*=TwosideKeeper.EXPLOSION_DMG_MULT;
damage_mult*=CalculateBlastResistance((LivingEntity)nearbyentities.get(i)); damage_mult*=CalculateBlastResistance((LivingEntity)nearbyentities.get(i));
double dmg = basedmg * damage_mult; TwosideKeeper.log("dmg mult is "+damage_mult,5);
dmg = basedmg * damage_mult;
if (nearbyentities.get(i) instanceof Player) {TwosideKeeper.log("Damage is "+dmg, 5);} if (nearbyentities.get(i) instanceof Player) {TwosideKeeper.log("Damage is "+dmg, 5);}
CustomDamage.ApplyDamage(dmg, null, (LivingEntity)nearbyentities.get(i), null, "Explosion", CustomDamage.NONE); CustomDamage.ApplyDamage(dmg, null, (LivingEntity)nearbyentities.get(i), null, "Explosion", CustomDamage.NONE);
//subtractHealth((LivingEntity)nearbyentities.get(i),null,NewCombat.CalculateDamageReduction(dmg, (LivingEntity)nearbyentities.get(i), null)); //subtractHealth((LivingEntity)nearbyentities.get(i),null,NewCombat.CalculateDamageReduction(dmg, (LivingEntity)nearbyentities.get(i), null));
@ -3581,4 +3633,50 @@ public class GenericFunctions {
} }
return testloc.getBlock().getLocation().add(0.5, 1.0, 0.5); return testloc.getBlock().getLocation().add(0.5, 1.0, 0.5);
} }
public static boolean isUpgradeShard(ItemStack item) {
return (item.getType()==Material.PRISMARINE_SHARD &&
item.containsEnchantment(Enchantment.LUCK));
}
public static int getUpgradeShardTier(ItemStack item) {
if (item!=null && isUpgradeShard(item)) {
ItemMeta meta = item.getItemMeta();
List<String> lore = item.getItemMeta().getLore();
for (int i=0;i<lore.size();i++) {
if (lore.get(i).contains(ChatColor.GOLD+""+ChatColor.BOLD+"T")) {
return Integer.valueOf(ChatColor.stripColor(lore.get(i).split(" ")[0].replace("T", "")));
}
}
lore.add(0,ChatColor.GOLD+""+ChatColor.BOLD+"T1 Set Upgrade Shard");
lore.add(1,"");
meta.setLore(lore);
item.setItemMeta(meta);
return 1;
} else {
return 0;
}
}
public static void setUpgradeShardTier(ItemStack item, int tier) {
if (item!=null && isUpgradeShard(item)) {
ItemMeta meta = item.getItemMeta();
List<String> lore = item.getItemMeta().getLore();
boolean found=false;
for (int i=0;i<lore.size();i++) {
if (lore.get(i).contains(ChatColor.GOLD+""+ChatColor.BOLD+"T")) {
//return Integer.valueOf(ChatColor.stripColor(lore.get(i).split(" ")[0].replace("T", "")));
lore.set(i, ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+" Set Upgrade Shard");
found=true;
break;
}
}
if (!found) {
lore.add(0,ChatColor.GOLD+""+ChatColor.BOLD+"T"+tier+" Set Upgrade Shard");
lore.add(1,"");
}
meta.setLore(lore);
item.setItemMeta(meta);
}
}
} }

View File

@ -21,7 +21,7 @@ public class CustomItem {
} }
public ItemStack getItemStack() { public ItemStack getItemStack() {
return item.clone(); return getItemStack(1);
} }
public ItemStack getItemStack(int amt) { public ItemStack getItemStack(int amt) {

View File

@ -0,0 +1,40 @@
package sig.plugin.TwosideKeeper.HelperStructures;
import java.util.List;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
public class CustomPotion extends CustomItem{
int max_amplifier;
int min_amplifier;
List<PotionEffect> effects;
public CustomPotion(ItemStack item,List<PotionEffect> effects, int min_amplifier, int max_amplifier) {
super(item);
this.min_amplifier=min_amplifier;
this.max_amplifier=max_amplifier;
this.effects=effects;
}
public ItemStack getItemStack(int amt) {
ItemStack temp = item.clone();
temp.setAmount(amt);
if (temp.getItemMeta() instanceof PotionMeta) {
PotionMeta pm = (PotionMeta)temp.getItemMeta();
for (int i=0;i<effects.size();i++) {
PotionEffect pe = effects.get(i);
pm.addCustomEffect(new PotionEffect(pe.getType(),pe.getDuration(),(int)((Math.random()*(max_amplifier-min_amplifier)))+min_amplifier),true);
}
temp.setItemMeta(pm);
}
return temp;
}
public ItemStack getItemStack() {
return this.getItemStack(1);
}
}

View File

@ -9,6 +9,7 @@ import org.bukkit.ChatColor;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import sig.plugin.TwosideKeeper.TwosideKeeper; import sig.plugin.TwosideKeeper.TwosideKeeper;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
@ -65,7 +66,7 @@ public enum ItemSet {
} }
public static int GetTier(ItemStack item) { public static int GetTier(ItemStack item) {
if (GenericFunctions.isEquip(item) && if (isSetItem(item) &&
item.getItemMeta().hasLore()) { item.getItemMeta().hasLore()) {
List<String> lore = item.getItemMeta().getLore(); List<String> lore = item.getItemMeta().getLore();
for (int i=0;i<lore.size();i++) { for (int i=0;i<lore.size();i++) {
@ -78,6 +79,31 @@ public enum ItemSet {
TwosideKeeper.log(ChatColor.RED+"[ERROR] Could not detect proper tier of "+item.toString()+"!", 1); TwosideKeeper.log(ChatColor.RED+"[ERROR] Could not detect proper tier of "+item.toString()+"!", 1);
return 0; return 0;
} }
public static void SetTier(ItemStack item, int tier) {
boolean found=false;
if (isSetItem(item) &&
item.getItemMeta().hasLore()) {
List<String> lore = item.getItemMeta().getLore();
for (int i=0;i<lore.size();i++) {
if (lore.get(i).contains(ChatColor.GOLD+""+ChatColor.BOLD+"T")) {
//This is the tier line.
int oldtier=GetTier(item);
//TwosideKeeper.log("In lore: "+lore.get(i)+". Old tier: "+oldtier,2);
lore.set(i, lore.get(i).replace("T"+oldtier, "T"+tier));
GenericFunctions.UpdateItemLore(item); //Update this item now that we upgraded the tier.
found=true;
break;
}
}
ItemMeta m = item.getItemMeta();
m.setLore(lore);
item.setItemMeta(m);
}
if (!found) {
TwosideKeeper.log(ChatColor.RED+"[ERROR] Could not detect proper tier of "+item.toString()+"!", 1);
}
}
public static int GetBaseAmount(ItemSet set, int tier, int stat) { public static int GetBaseAmount(ItemSet set, int tier, int stat) {
//stat will be 1 for the base value, 2 for the 2-piece set bonus, 3 for the 3-piece set bonus, and 4 for the 4-piece set bonus. //stat will be 1 for the base value, 2 for the 2-piece set bonus, 3 for the 3-piece set bonus, and 4 for the 4-piece set bonus.

View File

@ -197,8 +197,7 @@ public enum MonsterDifficulty {
new LootStructure(Material.LEATHER_BOOTS), new LootStructure(Material.LEATHER_BOOTS),
}, },
new LootStructure[]{ //Legendary Loot new LootStructure[]{ //Legendary Loot
new LootStructure(Material.PRISMARINE_SHARD), new LootStructure(Material.END_CRYSTAL),
new LootStructure(Material.POTION),
} }
); );

View File

@ -118,9 +118,11 @@ public class WorldShop {
item.getItemMeta().hasDisplayName()) { item.getItemMeta().hasDisplayName()) {
message+="\n"+ChatColor.DARK_GRAY+"Item Type: "+ChatColor.ITALIC+ChatColor.GRAY+GenericFunctions.UserFriendlyMaterialName(item.getType())+"\n"; message+="\n"+ChatColor.DARK_GRAY+"Item Type: "+ChatColor.ITALIC+ChatColor.GRAY+GenericFunctions.UserFriendlyMaterialName(item.getType())+"\n";
} }
for (int i=0;i<Enchantment.values().length;i++) { if (item.hasItemMeta() && !item.getItemMeta().getItemFlags().contains(ItemFlag.HIDE_ENCHANTS)) {
if (item.containsEnchantment(Enchantment.values()[i])) { for (int i=0;i<Enchantment.values().length;i++) {
message+="\n"+ChatColor.GRAY+getRealName(Enchantment.values()[i])+" "+toRomanNumeral(item.getEnchantmentLevel(Enchantment.getByName(Enchantment.values()[i].getName()))); //This is an enchantment we have. if (item.containsEnchantment(Enchantment.values()[i])) {
message+="\n"+ChatColor.GRAY+getRealName(Enchantment.values()[i])+" "+toRomanNumeral(item.getEnchantmentLevel(Enchantment.getByName(Enchantment.values()[i].getName()))); //This is an enchantment we have.
}
} }
} }
if (item.getType()==Material.ENCHANTED_BOOK) { if (item.getType()==Material.ENCHANTED_BOOK) {
@ -143,7 +145,7 @@ public class WorldShop {
message+="\n"+ChatColor.GRAY+book.getPageCount()+" page"+(book.getPageCount()!=1?"s":""); message+="\n"+ChatColor.GRAY+book.getPageCount()+" page"+(book.getPageCount()!=1?"s":"");
} }
} }
if (item.getType()==Material.POTION || item.getType()==Material.SPLASH_POTION || item.getType()==Material.LINGERING_POTION) { if (item.getType()==Material.POTION || item.getType()==Material.SPLASH_POTION || item.getType()==Material.LINGERING_POTION || item.getType()==Material.TIPPED_ARROW) {
if (item.getItemMeta() instanceof PotionMeta) { if (item.getItemMeta() instanceof PotionMeta) {
PotionMeta pot = (PotionMeta)item.getItemMeta(); PotionMeta pot = (PotionMeta)item.getItemMeta();
if (!pot.getItemFlags().contains(ItemFlag.HIDE_POTION_EFFECTS)) { if (!pot.getItemFlags().contains(ItemFlag.HIDE_POTION_EFFECTS)) {
@ -151,7 +153,7 @@ public class WorldShop {
for (int i=0;i<effects.size();i++) { for (int i=0;i<effects.size();i++) {
DecimalFormat df = new DecimalFormat("00"); DecimalFormat df = new DecimalFormat("00");
message+="\n"+ChatColor.GRAY+GenericFunctions.UserFriendlyPotionEffectTypeName(effects.get(i).getType())+" "+toRomanNumeral(effects.get(i).getAmplifier()+1)+ ((effects.get(i).getAmplifier()+1>0)?" ":"")+"("+effects.get(i).getDuration()/1200+":"+df.format((effects.get(i).getDuration()/20)%60)+")"; message+="\n"+ChatColor.GRAY+GenericFunctions.UserFriendlyPotionEffectTypeName(effects.get(i).getType())+" "+toRomanNumeral(effects.get(i).getAmplifier()+1)+ ((effects.get(i).getAmplifier()+1>0)?" ":"")+"("+toReadableDuration(effects.get(i).getDuration())+")";
} }
if (effects.size()==0) { //Try this instead. It might be a legacy potion. if (effects.size()==0) { //Try this instead. It might be a legacy potion.
@ -470,6 +472,11 @@ public class WorldShop {
return message; return message;
} }
public static String toReadableDuration(int duration) {
DecimalFormat df = new DecimalFormat("00");
return duration/1200+":"+df.format((duration/20)%60);
}
private static String obfuscateAllMagicCodes(String message) { private static String obfuscateAllMagicCodes(String message) {
StringBuilder newstring = new StringBuilder(""); StringBuilder newstring = new StringBuilder("");
boolean isMagic=false; boolean isMagic=false;
@ -488,11 +495,11 @@ public class WorldShop {
isColorCode=false; isColorCode=false;
} }
if (col!=null) { if (col!=null) {
TwosideKeeper.log("Col is "+col.name()+", char is "+message.charAt(i), 2); TwosideKeeper.log("Col is "+col.name()+", char is "+message.charAt(i), 5);
} }
if (col!=null && if (col!=null &&
col == ChatColor.MAGIC) { col == ChatColor.MAGIC) {
TwosideKeeper.log("Found a Magic Char at Line "+(linenumb+1)+", Character "+(charnumb+1), 2); TwosideKeeper.log("Found a Magic Char at Line "+(linenumb+1)+", Character "+(charnumb+1), 5);
WillBeMagic=true; WillBeMagic=true;
} }
if (col!=null && if (col!=null &&

View File

@ -149,6 +149,7 @@ import org.bukkit.event.world.WorldSaveEvent;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe; import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ShapedRecipe;
@ -191,6 +192,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.BankSession;
import sig.plugin.TwosideKeeper.HelperStructures.BowMode; import sig.plugin.TwosideKeeper.HelperStructures.BowMode;
import sig.plugin.TwosideKeeper.HelperStructures.CubeType; import sig.plugin.TwosideKeeper.HelperStructures.CubeType;
import sig.plugin.TwosideKeeper.HelperStructures.CustomItem; import sig.plugin.TwosideKeeper.HelperStructures.CustomItem;
import sig.plugin.TwosideKeeper.HelperStructures.CustomPotion;
import sig.plugin.TwosideKeeper.HelperStructures.CustomRecipe; import sig.plugin.TwosideKeeper.HelperStructures.CustomRecipe;
import sig.plugin.TwosideKeeper.HelperStructures.DeathStructure; import sig.plugin.TwosideKeeper.HelperStructures.DeathStructure;
import sig.plugin.TwosideKeeper.HelperStructures.ItemCube; import sig.plugin.TwosideKeeper.HelperStructures.ItemCube;
@ -261,9 +263,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public static CustomItem HUNTERS_COMPASS; public static CustomItem HUNTERS_COMPASS;
public static CustomItem UPGRADE_SHARD; public static CustomItem UPGRADE_SHARD;
public static CustomItem STRENGTHENING_VIAL; public static CustomPotion STRENGTHENING_VIAL;
public static CustomItem LIFE_VIAL; public static CustomPotion LIFE_VIAL;
public static CustomItem HARDENING_VIAL; public static CustomPotion HARDENING_VIAL;
public static final int DODGE_COOLDOWN=100; public static final int DODGE_COOLDOWN=100;
public static final int DEATHMARK_COOLDOWN=240; public static final int DEATHMARK_COOLDOWN=240;
@ -635,7 +637,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
int level=0; int level=0;
PotionEffectType type=null; PotionEffectType type=null;
for (int i1=0;i1<p.getActivePotionEffects().size();i1++) { for (int i1=0;i1<p.getActivePotionEffects().size();i1++) {
if (GenericFunctions.isBadEffect(Iterables.get(p.getActivePotionEffects(), i1).getType()) && Iterables.get(p.getActivePotionEffects(), i1).getDuration()>longestdur) { if (GenericFunctions.isBadEffect(Iterables.get(p.getActivePotionEffects(), i1).getType()) && Math.random()<=0.5) {
longestdur=Iterables.get(p.getActivePotionEffects(), i1).getDuration(); longestdur=Iterables.get(p.getActivePotionEffects(), i1).getDuration();
type=Iterables.get(p.getActivePotionEffects(), i1).getType(); type=Iterables.get(p.getActivePotionEffects(), i1).getType();
level=Iterables.get(p.getActivePotionEffects(), i1).getAmplifier(); level=Iterables.get(p.getActivePotionEffects(), i1).getAmplifier();
@ -940,49 +942,71 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}, 20l, 20l); }, 20l, 20l);
} }
private CustomItem DefineHardeningVial() { private CustomPotion DefineHardeningVial() {
ItemStack HARDENING_VIAL = new ItemStack(Material.POTION); ItemStack HARDENING_VIAL = new ItemStack(Material.POTION);
List<PotionEffect> effects = new ArrayList<PotionEffect>();
effects.add(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,20*60*15,0));
List<String> lore = new ArrayList<String>();
lore.add("A fantastic potion, it comes straight");
lore.add("from the elixir of the gods.");
PotionMeta pm = (PotionMeta)HARDENING_VIAL.getItemMeta(); PotionMeta pm = (PotionMeta)HARDENING_VIAL.getItemMeta();
pm.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,20*60*15,(int)(Math.random()*3+6)), true);
List<String> lore = new ArrayList<String>();
lore.add("A fantastic potion, it comes straight");
lore.add("from the elixir of the gods.");
pm.setLore(lore); pm.setLore(lore);
pm.setDisplayName("Hardening Vial"); pm.setDisplayName(ChatColor.GREEN+"Hardening Vial");
pm.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
HARDENING_VIAL.setItemMeta(pm); HARDENING_VIAL.setItemMeta(pm);
return new CustomItem(HARDENING_VIAL); return new CustomPotion(HARDENING_VIAL,effects,6,9);
} }
private CustomItem DefineLifeVial() { private CustomPotion DefineLifeVial() {
ItemStack LIFE_VIAL = new ItemStack(Material.POTION); ItemStack LIFE_VIAL = new ItemStack(Material.POTION);
PotionMeta pm = (PotionMeta)LIFE_VIAL.getItemMeta(); List<PotionEffect> effects = new ArrayList<PotionEffect>();
pm.addCustomEffect(new PotionEffect(PotionEffectType.ABSORPTION,20*60*15,(int)(Math.random()*50+50)), true); effects.add(new PotionEffect(PotionEffectType.ABSORPTION,20*60*15,0));
List<String> lore = new ArrayList<String>(); List<String> lore = new ArrayList<String>();
lore.add("A fantastic potion, it comes straight"); lore.add("A fantastic potion, it comes straight");
lore.add("from the elixir of the gods."); lore.add("from the elixir of the gods.");
PotionMeta pm = (PotionMeta)LIFE_VIAL.getItemMeta();
pm.setLore(lore); pm.setLore(lore);
pm.setDisplayName("Life Vial"); pm.setDisplayName(ChatColor.GREEN+"Life Vial");
pm.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
LIFE_VIAL.setItemMeta(pm); LIFE_VIAL.setItemMeta(pm);
return new CustomItem(LIFE_VIAL); return new CustomPotion(LIFE_VIAL,effects,50,100);
} }
private CustomItem DefineStrengtheningVial() { private CustomPotion DefineStrengtheningVial() {
ItemStack STRENGTHENING_VIAL = new ItemStack(Material.POTION);
List<PotionEffect> effects = new ArrayList<PotionEffect>();
effects.add(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,20*60*15,0));
List<String> lore = new ArrayList<String>();
lore.add("A fantastic potion, it comes straight");
lore.add("from the elixir of the gods.");
PotionMeta pm = (PotionMeta)STRENGTHENING_VIAL.getItemMeta();
pm.setLore(lore);
pm.setDisplayName(ChatColor.GREEN+"Strengthing Vial");
pm.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
STRENGTHENING_VIAL.setItemMeta(pm);
return new CustomPotion(STRENGTHENING_VIAL,effects,20,40);
/*//LEGACY CODE
ItemStack STRENGTHENING_VIAL = new ItemStack(Material.POTION); ItemStack STRENGTHENING_VIAL = new ItemStack(Material.POTION);
PotionMeta pm = (PotionMeta)STRENGTHENING_VIAL.getItemMeta(); PotionMeta pm = (PotionMeta)STRENGTHENING_VIAL.getItemMeta();
pm.addCustomEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,20*60*15,(int)(Math.random()*20+20)), true); int val=(int)(Math.random()*20+20);
pm.addCustomEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,20*60*15,val+1), true);
List<String> lore = new ArrayList<String>(); List<String> lore = new ArrayList<String>();
lore.add(ChatColor.GRAY+"Strength "+WorldShop.toRomanNumeral(val)+" ("+WorldShop.toReadableDuration(20*60*15)+")");
lore.add("");
lore.add("A fantastic potion, it comes straight"); lore.add("A fantastic potion, it comes straight");
lore.add("from the elixir of the gods."); lore.add("from the elixir of the gods.");
pm.setLore(lore); pm.setLore(lore);
pm.setDisplayName("Strengthing Vial"); pm.setDisplayName("Strengthing Vial");
pm.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
STRENGTHENING_VIAL.setItemMeta(pm); STRENGTHENING_VIAL.setItemMeta(pm);
return new CustomItem(STRENGTHENING_VIAL); return new CustomItem(STRENGTHENING_VIAL);*/
} }
private CustomItem DefineUpgradeShard() { private CustomItem DefineUpgradeShard() {
ItemStack UPGRADE_SHARD = new ItemStack(Material.PRISMARINE_SHARD); ItemStack UPGRADE_SHARD = new ItemStack(Material.PRISMARINE_SHARD);
ItemMeta meta = UPGRADE_SHARD.getItemMeta(); ItemMeta meta = UPGRADE_SHARD.getItemMeta();
meta.setDisplayName(ChatColor.GREEN+"Upgrade Shard"); meta.setDisplayName(ChatColor.GREEN+"Upgrade Shard");
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
List<String> UPGRADE_SHARD_lore = new ArrayList<String>(); List<String> UPGRADE_SHARD_lore = new ArrayList<String>();
UPGRADE_SHARD_lore.add("An eerie glow radiates from"); UPGRADE_SHARD_lore.add("An eerie glow radiates from");
UPGRADE_SHARD_lore.add("this item. It seems to possess"); UPGRADE_SHARD_lore.add("this item. It seems to possess");
@ -997,6 +1021,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ItemStack temp = new ItemStack(Material.COMPASS); ItemStack temp = new ItemStack(Material.COMPASS);
temp.addUnsafeEnchantment(Enchantment.LUCK, 1); temp.addUnsafeEnchantment(Enchantment.LUCK, 1);
ItemMeta m = temp.getItemMeta(); ItemMeta m = temp.getItemMeta();
m.addItemFlags(ItemFlag.HIDE_ENCHANTS);
m.setDisplayName(ChatColor.RED+"Hunter's Compass"); m.setDisplayName(ChatColor.RED+"Hunter's Compass");
List<String> lore = new ArrayList<String>(); List<String> lore = new ArrayList<String>();
lore.add("A compass for the true hunter."); lore.add("A compass for the true hunter.");
@ -1109,8 +1134,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (args.length>0) { if (args.length>0) {
((org.bukkit.craftbukkit.v1_9_R1.entity.CraftLivingEntity)p).getHandle().setAbsorptionHearts(Float.valueOf(args[0])); ((org.bukkit.craftbukkit.v1_9_R1.entity.CraftLivingEntity)p).getHandle().setAbsorptionHearts(Float.valueOf(args[0]));
}*/ }*/
Monster m = MonsterController.convertMonster((Monster)p.getWorld().spawnEntity(p.getLocation(),EntityType.ZOMBIE), MonsterDifficulty.ELITE); /*Monster m = MonsterController.convertMonster((Monster)p.getWorld().spawnEntity(p.getLocation(),EntityType.ZOMBIE), MonsterDifficulty.ELITE);
m.setHealth(m.getMaxHealth()/16d); m.setHealth(m.getMaxHealth()/16d);*/
//p.getWorld().dropItemNaturally(p.getLocation(), UPGRADE_SHARD.getItemStack());
//p.sendMessage("This is tier "+GenericFunctions.getUpgradeShardTier(p.getEquipment().getItemInMainHand()));
//ItemSet.SetTier(p.getEquipment().getItemInMainHand(), 7);
//p.getWorld().dropItemNaturally(p.getLocation(), STRENGTHENING_VIAL.getItemStack(50));
//TwosideKeeperAPI.spawnAdjustedMonster(MonsterType.GIANT, p.getLocation()); //TwosideKeeperAPI.spawnAdjustedMonster(MonsterType.GIANT, p.getLocation());
//TwosideKeeper.log("This is from set "+ItemSet.GetSet(p.getEquipment().getItemInMainHand())+" T"+ItemSet.GetTier(p.getEquipment().getItemInMainHand()),2); //TwosideKeeper.log("This is from set "+ItemSet.GetSet(p.getEquipment().getItemInMainHand())+" T"+ItemSet.GetTier(p.getEquipment().getItemInMainHand()),2);
/*Skeleton s = (Skeleton)p.getWorld().spawnEntity(p.getLocation(), EntityType.SKELETON); /*Skeleton s = (Skeleton)p.getWorld().spawnEntity(p.getLocation(), EntityType.SKELETON);
@ -4341,35 +4370,36 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
break; break;
} }
} }
if (em!=null && (ev.getTarget() instanceof Player) && !em.targetlist.contains((Player)ev.getTarget())) { if (em.targetlist.size()==0) {
Player p = (Player)ev.getTarget(); if (em!=null && (ev.getTarget() instanceof Player) && !em.targetlist.contains((Player)ev.getTarget())) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); Player p = (Player)ev.getTarget();
if (pd.lastdeath+em.WAIT_TIME<=TwosideKeeper.getServerTickTime()) { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
em.targetlist.add((Player)ev.getTarget()); if (pd.lastdeath+em.WAIT_TIME<=TwosideKeeper.getServerTickTime() && !CustomDamage.isInIframe(p)) {
} else { em.targetlist.add((Player)ev.getTarget());
log("This should trigger",5); m.setTarget(ev.getTarget());
em.randomlyTeleport(); } else {
em.randomlyTeleport(); log("This should trigger",5);
em.randomlyTeleport(); em.randomlyTeleport();
m.setTarget(null); em.randomlyTeleport();
em.targetlist.remove((Player)ev.getTarget()); em.randomlyTeleport();
em.myspawn=m.getLocation();
m.setTarget(null);
em.targetlist.remove((Player)ev.getTarget());
ev.setCancelled(true);
}
}
} else {
if (ev.getReason()!=TargetReason.CUSTOM &&
ev.getReason()!=TargetReason.UNKNOWN) {
ev.setCancelled(true); ev.setCancelled(true);
log("Unknown Targeting reason occurred for "+GenericFunctions.GetEntityDisplayName(m)+". Targeting: "+GenericFunctions.GetEntityDisplayName(m),1);
} }
} }
m.setTarget(ev.getTarget());
ev.setCancelled(true);
} else { } else {
log("This monster is "+MonsterController.getMonsterDifficulty(m).name(),5); log("This monster is "+MonsterController.getMonsterDifficulty(m).name(),5);
if (MonsterController.getMonsterDifficulty(m)==MonsterDifficulty.ELITE) { if (MonsterController.getMonsterDifficulty(m)==MonsterDifficulty.ELITE) {
EliteMonster em = new EliteMonster(m); EliteMonster em = new EliteMonster(m);
if (em!=null && (ev.getTarget() instanceof Player) && !em.targetlist.contains((Player)ev.getTarget())) { ms.SetElite(true);
Player p = (Player)ev.getTarget();
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (pd.lastdeath+em.WAIT_TIME<=TwosideKeeper.getServerTickTime()) {
em.randomlyTeleport();
}
ev.setCancelled(true);
}
elitemonsters.add(em); elitemonsters.add(em);
} }
} }
@ -4636,7 +4666,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
totalexp=ev.getDroppedExp()*20; totalexp=ev.getDroppedExp()*20;
ev.setDroppedExp((int)(totalexp*0.75)); ev.setDroppedExp((int)(totalexp*0.75));
final Monster mer1 = m; final Monster mer1 = m;
final int expdrop1 = totalexp; final int expdrop1 = totalexp;
droplist.clear(); //Clear the drop list. We are going to delay the drops. droplist.clear(); //Clear the drop list. We are going to delay the drops.
droplist.addAll(originaldroplist); droplist.addAll(originaldroplist);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@ -4705,6 +4735,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (DeathManager.getDeathStructure(p)!=null) { if (DeathManager.getDeathStructure(p)!=null) {
DeathManager.continueAction(p); DeathManager.continueAction(p);
} }
p.setVelocity(new Vector(0,0,0));
p.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,Integer.MAX_VALUE,255)); p.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,Integer.MAX_VALUE,255));
CustomDamage.setAbsorptionHearts(p, 0.0f); CustomDamage.setAbsorptionHearts(p, 0.0f);
GenericFunctions.addIFrame(p, Integer.MAX_VALUE); GenericFunctions.addIFrame(p, Integer.MAX_VALUE);
@ -4723,6 +4754,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setRespawnLocation(newloc.add(0,10,0)); ev.setRespawnLocation(newloc.add(0,10,0));
} }
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void KickEvent(PlayerKickEvent ev) {
if (ev.getReason()==null || (!ev.getReason().contains("ADMINKICK") && !ev.getReason().contains("Kicked by an operator."))) {
log("Tried to kick "+ev.getPlayer().getName()+" for reason "+ev.getReason(),1);
ev.setCancelled(true);
}
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void updateHealthbarHealEvent(EntityRegainHealthEvent ev) { public void updateHealthbarHealEvent(EntityRegainHealthEvent ev) {
Entity e = ev.getEntity(); Entity e = ev.getEntity();

View File

@ -294,7 +294,7 @@ public final class TwosideKeeperAPI {
//Recycling Center COMMANDS. //Recycling Center COMMANDS.
public static boolean isRecyclingCenter(Block b) { public static boolean isRecyclingCenter(Block b) {
return RecyclingCenter.isRecyclingCenter(b); return RecyclingCenter.isRecyclingCenter(b);
} }
//Item Set COMMANDS. //Item Set COMMANDS.
@ -312,6 +312,18 @@ public final class TwosideKeeperAPI {
public static int getItemTier(ItemStack item) { public static int getItemTier(ItemStack item) {
return ItemSet.GetTier(item); return ItemSet.GetTier(item);
} }
public static void setItemTier(ItemStack item,int tier) {
ItemSet.SetTier(item, tier);
}
public static boolean isUpgradeShard(ItemStack item) {
return GenericFunctions.isUpgradeShard(item);
}
public static int getUpgradeShardTier(ItemStack item) {
return GenericFunctions.getUpgradeShardTier(item);
}
public static void setUpgradeShardTier(ItemStack item, int tier) {
GenericFunctions.setUpgradeShardTier(item, tier);
}
//Localization COMMANDS. //Localization COMMANDS.
public static String getLocalizedItemName(ItemStack i) { public static String getLocalizedItemName(ItemStack i) {