Ranger mode and Bow arrow shooting fixed, while still preventing them

from being hit by Strikers. Obey hidden flags with item description.
This commit is contained in:
sigonasr2 2016-08-14 20:30:17 -05:00
parent 22e1dc51bc
commit e779ccb420
3 changed files with 76 additions and 72 deletions

Binary file not shown.

View File

@ -26,6 +26,7 @@ import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta;
import org.bukkit.inventory.meta.BlockStateMeta;
@ -125,9 +126,11 @@ public class WorldShop {
if (item.getType()==Material.ENCHANTED_BOOK) {
if (item.getItemMeta() instanceof EnchantmentStorageMeta) {
EnchantmentStorageMeta e = (EnchantmentStorageMeta)item.getItemMeta();
for (int i=0;i<Enchantment.values().length;i++) {
if (e.hasStoredEnchant((Enchantment.values()[i]))) {
message+="\n"+ChatColor.GRAY+getRealName(Enchantment.values()[i])+" "+toRomanNumeral(e.getStoredEnchantLevel(Enchantment.getByName(Enchantment.values()[i].getName()))); //This is an enchantment we have.
if (!e.getItemFlags().contains(ItemFlag.HIDE_ENCHANTS)) {
for (int i=0;i<Enchantment.values().length;i++) {
if (e.hasStoredEnchant((Enchantment.values()[i]))) {
message+="\n"+ChatColor.GRAY+getRealName(Enchantment.values()[i])+" "+toRomanNumeral(e.getStoredEnchantLevel(Enchantment.getByName(Enchantment.values()[i].getName()))); //This is an enchantment we have.
}
}
}
}
@ -143,79 +146,80 @@ public class WorldShop {
if (item.getType()==Material.POTION || item.getType()==Material.SPLASH_POTION || item.getType()==Material.LINGERING_POTION) {
if (item.getItemMeta() instanceof PotionMeta) {
PotionMeta pot = (PotionMeta)item.getItemMeta();
List<PotionEffect> effects = pot.getCustomEffects();
for (int i=0;i<effects.size();i++) {
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)+")";
}
if (effects.size()==0) { //Try this instead. It might be a legacy potion.
String duration = " "+(pot.getBasePotionData().isExtended()?"(8:00)":(pot.getBasePotionData().isUpgraded())?"(1:30)":"(3:00)");
String badduration = " "+(pot.getBasePotionData().isExtended()?"(4:00)":"(1:30)");
String poisonduration = " "+(pot.getBasePotionData().isExtended()?"(1:30)":(pot.getBasePotionData().isUpgraded())?"(0:21)":"(0:45)");
String luckduration = " (5:00)";
String regenduration = " "+(pot.getBasePotionData().isExtended()?"(1:30)":(pot.getBasePotionData().isUpgraded())?"(0:22)":"(0:45)");
String power = (pot.getBasePotionData().isUpgraded()?"II":"");
if (item.getType() == Material.LINGERING_POTION) {
duration = " "+(pot.getBasePotionData().isExtended()?"(2:00)":(pot.getBasePotionData().isUpgraded())?"(0:22)":"(0:45)");
badduration = " "+(pot.getBasePotionData().isExtended()?"(1:00)":"(0:22)");
poisonduration = " "+(pot.getBasePotionData().isExtended()?"(0:22)":(pot.getBasePotionData().isUpgraded())?"(0:05)":"(0:22)");
luckduration = " (1:15)";
regenduration = " "+(pot.getBasePotionData().isExtended()?"(0:22)":(pot.getBasePotionData().isUpgraded())?"(0:05)":"(0:11)");
if (!pot.getItemFlags().contains(ItemFlag.HIDE_POTION_EFFECTS)) {
List<PotionEffect> effects = pot.getCustomEffects();
for (int i=0;i<effects.size();i++) {
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)+")";
}
switch (pot.getBasePotionData().getType()) {
case FIRE_RESISTANCE:
message+="\n"+ChatColor.BLUE+"Fire Resistance"+duration;
break;
case INSTANT_DAMAGE:
message+="\n"+ChatColor.RED+"Instant Damage "+power;
break;
case INSTANT_HEAL:
message+="\n"+ChatColor.BLUE+"Instant Health "+power;
break;
case INVISIBILITY:
message+="\n"+ChatColor.BLUE+"Invisibility"+duration;
break;
case JUMP:
message+="\n"+ChatColor.BLUE+"Jump Boost "+power+duration;
break;
case LUCK:
message+="\n"+ChatColor.BLUE+"Luck"+luckduration;
break;
case NIGHT_VISION:
message+="\n"+ChatColor.BLUE+"Night Vision"+duration;
break;
case POISON:
message+="\n"+ChatColor.RED+"Poison "+power+badduration;
break;
case REGEN:
message+="\n"+ChatColor.BLUE+"Regeneration "+power+duration;
break;
case SLOWNESS:
message+="\n"+ChatColor.RED+"Slowness"+badduration;
break;
case SPEED:
message+="\n"+ChatColor.BLUE+"Speed "+power+duration;
break;
case STRENGTH:
message+="\n"+ChatColor.BLUE+"Strength "+power+duration;
break;
case WATER_BREATHING:
message+="\n"+ChatColor.BLUE+"Water Breathing"+duration;
break;
case WEAKNESS:
message+="\n"+ChatColor.RED+"Weakness"+badduration;
break;
default:
message+="\n"+ChatColor.GRAY+"No Effects";
break;
if (effects.size()==0) { //Try this instead. It might be a legacy potion.
String duration = " "+(pot.getBasePotionData().isExtended()?"(8:00)":(pot.getBasePotionData().isUpgraded())?"(1:30)":"(3:00)");
String badduration = " "+(pot.getBasePotionData().isExtended()?"(4:00)":"(1:30)");
String poisonduration = " "+(pot.getBasePotionData().isExtended()?"(1:30)":(pot.getBasePotionData().isUpgraded())?"(0:21)":"(0:45)");
String luckduration = " (5:00)";
String regenduration = " "+(pot.getBasePotionData().isExtended()?"(1:30)":(pot.getBasePotionData().isUpgraded())?"(0:22)":"(0:45)");
String power = (pot.getBasePotionData().isUpgraded()?"II":"");
if (item.getType() == Material.LINGERING_POTION) {
duration = " "+(pot.getBasePotionData().isExtended()?"(2:00)":(pot.getBasePotionData().isUpgraded())?"(0:22)":"(0:45)");
badduration = " "+(pot.getBasePotionData().isExtended()?"(1:00)":"(0:22)");
poisonduration = " "+(pot.getBasePotionData().isExtended()?"(0:22)":(pot.getBasePotionData().isUpgraded())?"(0:05)":"(0:22)");
luckduration = " (1:15)";
regenduration = " "+(pot.getBasePotionData().isExtended()?"(0:22)":(pot.getBasePotionData().isUpgraded())?"(0:05)":"(0:11)");
}
switch (pot.getBasePotionData().getType()) {
case FIRE_RESISTANCE:
message+="\n"+ChatColor.BLUE+"Fire Resistance"+duration;
break;
case INSTANT_DAMAGE:
message+="\n"+ChatColor.RED+"Instant Damage "+power;
break;
case INSTANT_HEAL:
message+="\n"+ChatColor.BLUE+"Instant Health "+power;
break;
case INVISIBILITY:
message+="\n"+ChatColor.BLUE+"Invisibility"+duration;
break;
case JUMP:
message+="\n"+ChatColor.BLUE+"Jump Boost "+power+duration;
break;
case LUCK:
message+="\n"+ChatColor.BLUE+"Luck"+luckduration;
break;
case NIGHT_VISION:
message+="\n"+ChatColor.BLUE+"Night Vision"+duration;
break;
case POISON:
message+="\n"+ChatColor.RED+"Poison "+power+badduration;
break;
case REGEN:
message+="\n"+ChatColor.BLUE+"Regeneration "+power+duration;
break;
case SLOWNESS:
message+="\n"+ChatColor.RED+"Slowness"+badduration;
break;
case SPEED:
message+="\n"+ChatColor.BLUE+"Speed "+power+duration;
break;
case STRENGTH:
message+="\n"+ChatColor.BLUE+"Strength "+power+duration;
break;
case WATER_BREATHING:
message+="\n"+ChatColor.BLUE+"Water Breathing"+duration;
break;
case WEAKNESS:
message+="\n"+ChatColor.RED+"Weakness"+badduration;
break;
default:
message+="\n"+ChatColor.GRAY+"No Effects";
break;
}
}
}
}
}

View File

@ -5375,6 +5375,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
}
arr.setCustomName("HIT");
}
}
}
@ -5399,7 +5400,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.getProjectile().getType()==EntityType.TIPPED_ARROW)) {
//Now we know this is a player who shot a regular old arrow.
final Player p = (Player)ev.getEntity();
ev.getProjectile().setCustomName("HIT");
//We need to give one back to them.
if (ev.getProjectile().getType()==EntityType.ARROW) {
//This was an arrow quiver. We need to verify that, check the player's inventory for one.