Timtower

Pythoncode

Nov 16th, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. @hook.event("player.PlayerInteractEvent","HIGHEST")
  2. def onPlayerInteractEvent(event):
  3.  
  4.  
  5. @hook.event("player.PlayerItemHeldEvent", "HIGHEST")
  6. def onPlayerItemHeldEvent(event):
  7. section = pyplugin.getCfg().getConfigurationSection("main")
  8. keys = section.getKeys(0)
  9. for currentKey in keys:
  10. effectname = section.getString("%s.effect"%currentKey)
  11. duration = section.getInt("%s.duration"%currentKey)
  12. durationinticks = duration * 20
  13. amplifier = section.getInt("%s.amplifier"%currentKey)
  14. clickable = section.getString("%s.clickable"%currentKey)
  15. iteminhand = event.getPlayer().getItemInHand().getType().name()
  16. effect_type = getattr(PotionEffectType, effectname)
  17. potion_effect = PotionEffect(effect_type, durationinticks, amplifier)
  18. currentslot = event.getPlayer().getInventory().getHeldItemSlot()
  19. lastslot = event.getNewSlot()
  20. print effect_type
  21. print "Current slot: %s" % currentslot
  22. print "Lastslot: %s" % lastslot
  23. if iteminhand == currentKey:
  24. if clickable == "false":
  25. if currentslot != lastslot:
  26. event.getPlayer().removePotionEffect(effect_type)
  27. else:
  28. pass
  29. if event.getPlayer().hasPermission("itemeffect.geteffect"):
  30. section = pyplugin.getCfg().getConfigurationSection("main")
  31. keys = section.getKeys(0)
  32. for currentKey in keys:
  33. effectname = section.getString("%s.effect"%currentKey)
  34. duration = section.getInt("%s.duration"%currentKey)
  35. durationinticks = duration * 20
  36. amplifier = section.getInt("%s.amplifier"%currentKey)
  37. clickable = section.getString("%s.clickable"%currentKey)
  38. iteminhand = event.getPlayer().getItemInHand().getType().name()
  39. effect_type = getattr(PotionEffectType, effectname)
  40. potion_effect = PotionEffect(effect_type, durationinticks, amplifier)
  41. if clickable == "true":
  42. if (event.getAction() == event.action.RIGHT_CLICK_AIR) or (event.getAction() == event.action.RIGHT_CLICK_BLOCK):
  43. if iteminhand == currentKey:
  44. event.getPlayer().addPotionEffect(potion_effect)
  45. if clickable == "false":
  46. if iteminhand == currentKey:
  47. event.getPlayer().addPotionEffect(potion_effect)
Advertisement
Add Comment
Please, Sign In to add comment