예제 #1
0
def OnCommandRename(sender, args):
    if not args:
        return False

    argstring = Colorify(' '.join(args))

    item = sender.getItemInHand()

    meta = item.getItemMeta()

    if meta == None:
        SendError(sender, "No item in hand")
        return True

    meta.setDisplayName(argstring)

    item.setItemMeta(meta)

    SendInfo(sender, "Renamed item!")

    return True
예제 #2
0
def OnCommandFoodfight(sender, args):
    if len(args) == 0:
        SendError(sender, "Usage: /slap [Player] [Object]")
        return True

    receiver = Bukkit.getPlayer(args[0])

    if receiver == None:
        SendError(sender, 'No such player.')
        return True

    if len(args) > 1:
        item = ' '.join(args[1:])
        number = '1'

        for i in args[1:]:
            if not i.isdigit() and i != 'some':
                if number != 1:
                    if i[len(i) - 1:] == 's':
                        Sudo(' '.join(('give', receiver.getName(),
                                       i[:len(i) - 1], number)))

                        if i[len(i) - 2:] == 'es':
                            Sudo(' '.join(('give', receiver.getName(),
                                           i[:len(i) - 2], number)))

                    else:
                        Sudo(' '.join(
                            ('give ', receiver.getName(), i, number)))

                else:
                    Sudo(' '.join(('give ', receiver.getName(), i, '1')))

            number = 1

            if i == 'some':
                number = str(random.randint(2, 8))

            if i.isdigit():
                number = i

        Word1 = args[1]

    else:
        item = 'large trout'
        i = 'fishy'
        Word1 = 'large'

        material = None

        GiveItem(receiver, 349)  # Fish

    if receiver == sender:
        receiverName = 'themselves'
    else:
        receiverName = receiver.getName()

    if not (Word1 == 'some' or Word1.isdigit()):
        if Word1[0].lower() in Vowels:
            amount = 'an '
        else:
            amount = 'a '
    else:
        amount = ''

    Bukkit.broadcastMessage(
        Color("5") + sender.getName() + Color("c") + " slapped " + Color("5") +
        receiverName + Color("c") + " about a bit with " + amount +
        Color("6") + item)

    if random.randint(0, 1):
        receiver.addPotionEffect(
            PotionEffect(PotionEffectType.CONFUSION, 160, 3, True))
    else:
        receiver.addPotionEffect(
            PotionEffect(PotionEffectType.SLOW, 40, 1, True))

    return True
예제 #3
0
def OnCommandItemname(sender, args):
    if len(args) == 0:
        SendError(
            sender, "You must have an argument -" + Color("6") +
            " /eff [effect] [power] [duration]" + Color("c") +
            " you can also use 'rem' and 'list' as effects, for special functions"
        )
        return True

    if args[0] == "rem":
        if len(args) < 2:
            for effect in sender.getActivePotionEffects():
                sender.removePotionEffect(effect.getType())

            return True

        elif int(args[1]) < sender.getActivePotionEffects():
            effect = sender.getActivePotionEffects()[int(args[1])]
            sender.removePotionEffect(effect.getType())

            return True

    if args[0] == "list":
        if len(args) < 2:
            Bukkit.dispatchCommand(sender, "e")
        else:
            Bukkit.dispatchCommand(sender, "e " + args[1])

        return True

    if len(args) < 3:
        SendError(
            sender, "You must have the correct amount of arguments -" +
            Color("6") + " /eff [effect] [power] [duration]")
        return True

    for i in range(1, 2):
        if args[i].isdigit() == False:
            sender.sendMessage(
                Color("c") + "Your power and duration must be integers -" +
                Color("6") + " /eff [effect] [power] [duration]")
            return False

    args[0] = args[0].upper()
    args[0] = args[0].replace(" ", "")
    args[0] = args[0].replace(".", "")

    if len(args) == 4:
        receiver = Bukkit.getPlayer(args[3])

        if receiver == None:
            SendError("Invalid player")
            return True

    else:
        receiver = sender

    EffectStr = "PotionEffectType." + args[0]

    try:
        receiver.addPotionEffect(
            PotionEffect(eval(EffectStr), int(args[2]), int(args[1] - 1)))
    except:
        sender.sendMessage("Invalid effect")

    return True