move cycle plugin to new module; add features

This commit is contained in:
jomo
2014-06-29 15:18:25 +02:00
parent 91e826aec0
commit dd8fe14858
4 changed files with 69 additions and 22 deletions

21
misc.py
View File

@@ -92,27 +92,6 @@ def onPlayerInteractEntity(event):
sender.playSound(entity.getLocation(), "mob.cow.say", 1, 1)
#
# Cycling around the item bar will switch between rows of the inventory
#
@hook.event("player.PlayerItemHeldEvent", "normal")
def onHeldEvent(event):
player = event.getPlayer()
prev_slot = event.getPreviousSlot()
new_slot = event.getNewSlot()
if (prev_slot == 0 and new_slot == 8):
doCycle(player, -9)
elif (prev_slot == 8 and new_slot == 0):
doCycle(player, 9)
def doCycle(player, e):
inv = player.getInventory()
inv2 = inv.getContents()
e = e % len(inv2)
inv2 = inv2[e:] + inv2[:e]
inv.setContents(inv2)
#
# Various text commands
#