add 0.4s delay to shearing

This commit is contained in:
jomo
2014-07-05 21:12:27 +02:00
parent 1c2c3782c7
commit fd212674c1

21
misc.py
View File

@@ -1,5 +1,6 @@
#pylint: disable=F0401 #pylint: disable=F0401
from helpers import * from helpers import *
from time import time as now
import org.bukkit.inventory.ItemStack as ItemStack import org.bukkit.inventory.ItemStack as ItemStack
# #
@@ -74,16 +75,22 @@ def onSudoCommand(sender, args):
# Clicking redstone_sheep with shears will drop redstone + wool and makes a moo sound # Clicking redstone_sheep with shears will drop redstone + wool and makes a moo sound
# #
last_shear = 0.0
@hook.event("player.PlayerInteractEntityEvent") @hook.event("player.PlayerInteractEntityEvent")
def onPlayerInteractEntity(event): def onPlayerInteractEntity(event):
global last_shear
if not event.isCancelled(): if not event.isCancelled():
sender = event.getPlayer() shear_time = now()
entity = event.getRightClicked() if last_shear + 0.4 < shear_time:
if isPlayer(entity) and str(entity.getUniqueId()) == "ae795aa8-6327-408e-92ab-25c8a59f3ba1" and str(sender.getItemInHand().getType()) == "SHEARS" and str(sender.getGameMode()) == "CREATIVE": last_shear = shear_time
for i in range(5): sender = event.getPlayer()
entity.getWorld().dropItemNaturally(entity.getLocation(), ItemStack(bukkit.Material.getMaterial("REDSTONE"))) entity = event.getRightClicked()
entity.getWorld().dropItemNaturally(entity.getLocation(), ItemStack(bukkit.Material.getMaterial("WOOL"))) if isPlayer(entity) and str(entity.getUniqueId()) == "ae795aa8-6327-408e-92ab-25c8a59f3ba1" and str(sender.getItemInHand().getType()) == "SHEARS" and str(sender.getGameMode()) == "CREATIVE":
sender.playSound(entity.getLocation(), "mob.cow.say", 1, 1) for i in range(5):
entity.getWorld().dropItemNaturally(entity.getLocation(), ItemStack(bukkit.Material.getMaterial("REDSTONE")))
entity.getWorld().dropItemNaturally(entity.getLocation(), ItemStack(bukkit.Material.getMaterial("WOOL")))
sender.playSound(entity.getLocation(), "mob.cow.say", 1, 1)
# #