Fix artifact bugs not giving experience. Made Mending and Infinity drop
off from items occasionally.
This commit is contained in:
parent
dc338d3a64
commit
5a53a36f67
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
name: TwosideKeeper
|
||||
main: sig.plugin.TwosideKeeper.TwosideKeeper
|
||||
version: 3.5.1
|
||||
version: 3.5.1a
|
||||
commands:
|
||||
money:
|
||||
description: Tells the player the amount of money they are holding.
|
||||
|
@ -1656,7 +1656,8 @@ public class GenericFunctions {
|
||||
if (item.getType().toString().contains("BOW") ||
|
||||
item.getType().toString().contains("AXE") ||
|
||||
item.getType().toString().contains("SWORD") ||
|
||||
item.getType().toString().contains("FISHING_ROD")) {
|
||||
item.getType().toString().contains("FISHING_ROD") ||
|
||||
item.getType().toString().contains("HOE")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -2008,4 +2009,31 @@ public class GenericFunctions {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack RemovePermEnchantmentChance(ItemStack item, Player p) {
|
||||
if (item!=null &&
|
||||
item.getType()!=Material.AIR) {
|
||||
int mendinglv = item.getEnchantmentLevel(Enchantment.MENDING);
|
||||
int infinitylv = item.getEnchantmentLevel(Enchantment.ARROW_INFINITE);
|
||||
if (mendinglv>0 && Math.random()<=0.00048828125) {
|
||||
mendinglv--;
|
||||
if (mendinglv>0) {
|
||||
item.addUnsafeEnchantment(Enchantment.MENDING, mendinglv);
|
||||
} else {
|
||||
item.removeEnchantment(Enchantment.MENDING);
|
||||
}
|
||||
p.sendMessage(ChatColor.DARK_AQUA+"A level of "+ChatColor.YELLOW+"Mending"+ChatColor.DARK_AQUA+" has been knocked off of your "+((item.hasItemMeta() && item.getItemMeta().hasDisplayName())?item.getItemMeta().getDisplayName():UserFriendlyMaterialName(item)));
|
||||
}
|
||||
if (infinitylv>0 && Math.random()<=0.00048828125) {
|
||||
infinitylv--;
|
||||
if (infinitylv>0) {
|
||||
item.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, infinitylv);
|
||||
} else {
|
||||
item.removeEnchantment(Enchantment.ARROW_INFINITE);
|
||||
}
|
||||
p.sendMessage(ChatColor.DARK_AQUA+"A level of "+ChatColor.YELLOW+"Infinity"+ChatColor.DARK_AQUA+" has been knocked off of your "+((item.hasItemMeta() && item.getItemMeta().hasDisplayName())?item.getItemMeta().getDisplayName():UserFriendlyMaterialName(item)));
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
@ -98,6 +98,8 @@ import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerChatTabCompleteEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerExpChangeEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent.State;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemBreakEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
@ -3326,6 +3328,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
GenericFunctions.isArtifactArmor(p.getEquipment().getArmorContents()[i])) {
|
||||
AwakenedArtifact.addPotentialEXP(p.getEquipment().getArmorContents()[i], (int)rawdmg, p);
|
||||
}
|
||||
|
||||
if (GenericFunctions.isArmor(p.getEquipment().getArmorContents()[i])) {
|
||||
GenericFunctions.RemovePermEnchantmentChance(p.getEquipment().getArmorContents()[i], p);
|
||||
}
|
||||
}
|
||||
|
||||
log("Final dmg is "+ev.getFinalDamage(),4);
|
||||
@ -3441,6 +3447,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
}}
|
||||
,100);
|
||||
}
|
||||
if (GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) {
|
||||
GenericFunctions.RemovePermEnchantmentChance(p.getEquipment().getItemInMainHand(), p);
|
||||
}
|
||||
|
||||
//Artifact armor will receive a tiny bit of EXP.
|
||||
for (int i=0;i<p.getEquipment().getArmorContents().length;i++) {
|
||||
@ -3506,6 +3515,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
GenericFunctions.isArtifactArmor(p.getEquipment().getArmorContents()[i])) {
|
||||
AwakenedArtifact.addPotentialEXP(p.getEquipment().getArmorContents()[i], (int)rawdmg, p);
|
||||
}
|
||||
if (GenericFunctions.isArmor(p.getEquipment().getArmorContents()[i])) {
|
||||
GenericFunctions.RemovePermEnchantmentChance(p.getEquipment().getArmorContents()[i], p);
|
||||
}
|
||||
}
|
||||
|
||||
//Make this monster the player's new target.
|
||||
@ -3576,14 +3588,17 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
ev.setDamage(ev.getDamage()-(ev.getDamage()*dmgincrease/100));
|
||||
log("True damage dealt: "+truedmg,5);
|
||||
}
|
||||
if (GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) {
|
||||
GenericFunctions.RemovePermEnchantmentChance(p.getEquipment().getItemInMainHand(), p);
|
||||
}
|
||||
ev.setDamage(CalculateDamageReduction(ev.getDamage(),m,p)+truedmg);
|
||||
log("Reduced damage is "+ev.getDamage(),5);
|
||||
|
||||
double ratio = 1.0-CalculateDamageReduction(1,m,p);
|
||||
if (GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) &&
|
||||
GenericFunctions.isArtifactWeapon(p.getEquipment().getItemInMainHand())) {
|
||||
log("EXP ratio is "+ratio,5);
|
||||
AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), (int)(ratio*20), p);
|
||||
log("EXP ratio is "+ratio,2);
|
||||
AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), (int)(ratio*20)+5, p);
|
||||
}
|
||||
|
||||
//Artifact armor will receive a tiny bit of EXP.
|
||||
@ -3634,12 +3649,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
boolean killedByPlayer = false;
|
||||
final Location deathloc = m.getLocation();
|
||||
|
||||
if (m.getKiller()!=null) {
|
||||
if (m.getTarget()!=null && (m.getTarget() instanceof Player)) {
|
||||
killedByPlayer = true;
|
||||
}
|
||||
|
||||
if (m.getKiller() instanceof Player) {
|
||||
Player p = (Player)m.getKiller();
|
||||
if (m.getTarget() instanceof Player) {
|
||||
Player p = (Player)m.getTarget();
|
||||
PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
|
||||
dropmult+=pd.partybonus*0.33; //Party bonus increases drop rate by 33% per party member.
|
||||
ItemStack item = p.getEquipment().getItemInMainHand();
|
||||
@ -3673,7 +3688,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
//Get the player that killed the monster.
|
||||
int luckmult = 0;
|
||||
int unluckmult = 0;
|
||||
Player p = (Player)m.getKiller();
|
||||
Player p = (Player)m.getTarget();
|
||||
if (p.hasPotionEffect(PotionEffectType.LUCK) ||
|
||||
p.hasPotionEffect(PotionEffectType.UNLUCK)) {
|
||||
for (int i=0;i<p.getActivePotionEffects().size();i++) {
|
||||
@ -3831,6 +3846,22 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.LOW)
|
||||
public void onFishEvent(PlayerFishEvent ev) {
|
||||
if (ev.getState().equals(State.CAUGHT_FISH)) {
|
||||
Player p = ev.getPlayer();
|
||||
if (p!=null) {
|
||||
if (GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) &&
|
||||
GenericFunctions.isArtifactWeapon(p.getEquipment().getItemInMainHand())) {
|
||||
AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), 12, p);
|
||||
}
|
||||
if (GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) {
|
||||
GenericFunctions.RemovePermEnchantmentChance(p.getEquipment().getItemInMainHand(), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.LOW)
|
||||
public void onBlockBreak(BlockBreakEvent ev) {
|
||||
|
||||
@ -3843,6 +3874,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
GenericFunctions.isArtifactTool(p.getEquipment().getItemInMainHand())) {
|
||||
AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), 4, p);
|
||||
}
|
||||
if (GenericFunctions.isTool(p.getEquipment().getItemInMainHand())) {
|
||||
GenericFunctions.RemovePermEnchantmentChance(p.getEquipment().getItemInMainHand(), p);
|
||||
}
|
||||
}
|
||||
|
||||
if (ev.getBlock().getType()==Material.WALL_SIGN ||
|
||||
|
Loading…
x
Reference in New Issue
Block a user