def on_quit(event): uuid = uid(event.getPlayer()) if uuid in toggle_dict: del toggle_dict[uuid] for pid in list(toggle_dict): if toggle_dict[pid] == uuid: del toggle_dict[pid] msg( Bukkit.getPlayer(juuid(pid)), "%s &cwent off so your Private Message Toggle has been disabled!" % Bukkit.getPlayer(juuid(uuid)).getDisplayName())
def on_quit(event): uuid = uid(event.getPlayer()) if uuid in toggle_dict: del toggle_dict[uuid] for pid in list(toggle_dict): if toggle_dict[pid] == uuid: del toggle_dict[pid] msg( Bukkit.getPlayer(juuid(pid)), "%s &cwent off so your Private Message Toggle has been disabled!" % Bukkit.getPlayer(juuid(uuid)).getDisplayName(), )
def OnCommandFoodfight(sender, args): if len(args) == 0: SendError(sender, "You must specify who you are to throw food at.") return True Item = random.choice(Food.items()) receiver = Bukkit.getPlayer(args[0]) if receiver == None: SendError(sender, 'No such player.') return True GiveItem(receiver, Item[1]) Singular = ('a ', 'an ')[Item[0][0] in Vowels] Name = sender.getName() RName = receiver.getName() Bukkit.broadcastMessage( Color("5") + Name + Color("e") + " threw " + Singular + Color("6") + Item[0] + Color("c") + " at " + Color("5") + RName) if random.randint(1, 5) == 1: receiver.addPotionEffect( PotionEffect(PotionEffectType.BLINDNESS, 40, 1, True)) Bukkit.broadcastMessage(Color("5") + "Headshot!") return True
def onCommandFoodfight(sender,args): if len(args) == 0: sender.sendMessage(color("c") + "You must specify who you are to throw food at.") return False Item = random.choice(Food.items()) receiver = Bukkit.getPlayer(args[0]) if receiver == None: sender.sendMessage(color("c") + 'No such player.') return False Sudo("give " + args[0] + ' ' + Item[1] + " 1") Singular = ('a ', 'an ')[Item[0][0] in vowels] Name = sender.getName() RName = receiver.getName() Bukkit.broadcastMessage(color("5") + Name + color("e") + " threw "+ Singular + color("6") + Item[0] + color("c") + " at " + color("5") + RName) if random.randint(1,5) == 1: receiver.addPotionEffect(PotionEffect(PotionEffectType.BLINDNESS, 40, 1, True)) Bukkit.broadcastMessage(color("5") + "Headshot!") return True
def onCommandFoodfight(sender,args): if len(args) == 0: sender.sendMessage(''.join([color("c"),"You must specify who you are to throw food at."])) return False food = random.randint(1,(len(foodlistitem)-1)) receiver = Bukkit.getPlayer(args[0]) if receiver == None: sender.sendMessage(''.join([color('c'),'No such player.'])) return False sudo(''.join(["give ",args[0],foodlistitem[food]," 1"])) if food == 1: Bukkit.broadcastMessage(''.join([color("5"),sender.getName(),color("c")," threw an ",color("6"),"apple",color("c")," at ",color("5"),receiver.getName()])) else: Bukkit.broadcastMessage(''.join([color("5"),sender.getName(),color("c")," threw a ",color("6"),foodlistname[food],color("c")," at ",color("5"),receiver.getName()])) if random.randint(1,5) == 1: receiver.addPotionEffect(PotionEffect(PotionEffectType.BLINDNESS, 40, 1, True)) Bukkit.broadcastMessage(''.join([color("5"),"Headshot!"])) return True
def on_toggle_message_command(sender, command, label, args): if not sender.hasPermission(permission) or not is_player(sender): noperm(sender) return True plugin_header(sender, "Private Message Toggle") uuid = uid(sender) if len(args) > 0: if len(args) > 1: msg(sender, "&cToo many arguments!") return True target = Bukkit.getPlayer(args[0]) if target: toggle_dict[uuid] = uid(target) msg( sender, "&2Enabled toggle so that you're now sending only to %s &2by default" % target.getDisplayName()) else: msg(sender, "&cThat player could not be found") elif uuid in toggle_dict: del toggle_dict[uuid] msg(sender, "&2Disabled toggle successfully") else: msg(sender, "&cExpected a player as argument") return True
def onPayGem(self, sender, args): if self.iconomy is None: sender.sendMessage("Vault not found!") return if not sender.isOp(): sender.sendMessage("Only for OP!") return if len(args) < 3: sender.sendMessage("Usage: paygem <player> <cost> <gemname>") return namePlayer = args[0] cost = float(args[1]) nameGem = args[2] player = Bukkit.getPlayer(namePlayer) if not self.iconomy.has(namePlayer, cost): player.sendMessage(u"%sНе хватает денег на покупку. Требуется %d голд." % (ChatColor.RED, cost)) return self.iconomy.withdrawPlayer(namePlayer, cost) server = Bukkit.getServer() server.dispatchCommand(server.getConsoleSender(), "md gem %s -a 1 -g %s" % (namePlayer, nameGem))
def onGetExp(self, sender, args): if self.pheroes is None: sender.sendMessage("Heroes not found!") return if not sender.isOp(): sender.sendMessage("Only for OP!") return if len(args) < 2: sender.sendMessage("Usage: getexp <player> <exp>") return namePlayer = args[0] exp = int(args[1]) player = Bukkit.getPlayer(namePlayer) if player is None: sender.sendMessage("%sPlayer not found!" % ChatColor.RED) return hero = self.pheroes.getCharacterManager().getHero(player) if hero is None: sender.sendMessage("%sHero not found!" % ChatColor.RED) return heroClass = hero.getHeroClass() heroLevel = hero.getLevel(heroClass) if heroLevel >= heroClass.getMaxLevel(): player.sendMessage(u"%sУ вас уже максимальный уровень." % ChatColor.RED) else: hero.addExp(exp, heroClass, player.getLocation()) player.sendMessage(u"%sПолучено %d опыта." % (ChatColor.GREEN, exp))
def OnCommandFoodfight(sender,args): if len(args) == 0: SendError(sender, "You must specify who you are to throw food at.") return True Item = random.choice(Food.items()) receiver = Bukkit.getPlayer(args[0]) if receiver == None: SendError(sender, 'No such player.') return True GiveItem(receiver, Item[1]) Singular = ('a ', 'an ')[Item[0][0] in Vowels] Name = sender.getName() RName = receiver.getName() Bukkit.broadcastMessage(Color("5") + Name + Color("e") + " threw " + Singular + Color("6") + Item[0] + Color("c") + " at " + Color("5") + RName) if random.randint(1, 5) == 1: receiver.addPotionEffect(PotionEffect(PotionEffectType.BLINDNESS, 40, 1, True)) Bukkit.broadcastMessage(Color("5") + "Headshot!") return True
def onCommandFoodfight(sender,args): if len(args) == 0: sender.sendMessage(color("c") + "/slap [Player] [Thing]") return False receiver = Bukkit.getPlayer(args[0]) if receiver == None: sender.sendMessage(color("c") + 'No such player.') return False 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' Sudo('give '+receiver.getName()+' fish 1') i = 'fishy' Word1 = 'large' material = None 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
def on_chat(event): if event.isCancelled(): return player = event.getPlayer() uuid = uid(player) if uuid in toggle_dict: event.setCancelled(True) target = Bukkit.getPlayer(juuid(toggle_dict[uuid])).getName() runas(player, "msg %s %s" % (target, event.getMessage()))
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
def onCommandHug(sender, args): if len(args) == 0: sender.sendMessage(''.join([color("c"),"You must have an argument -",color("6")," /hug [thing]"])) return False if Bukkit.getPlayer(args[0]) != None: receiverPlayer = Bukkit.getPlayer(args[0]) receiverPlayer.sendMessage(''.join([color("d"),"You were hugged by ",sender.getName()])) receiver = receiverPlayer.getName() sender.sendMessage(''.join([color("d"),"You hugged ",receiver])) else: receiver = args[0] Bukkit.broadcastMessage(''.join([color(str(hex(random.randint(1,15)))[2]),color(str(hex(random.randint(1,15)))[2]),sender.getName(),color(str(hex(random.randint(1,15)))[2])," hugged ",color(str(hex(random.randint(1,15)))[2]),receiver])) return True
def onCommandFixme(sender, args): if len(args) == 1: receiver = Bukkit.getPlayer(args[0]) else: receiver = sender Bukkit.dispatchCommand(receiver,"eff rem") receiver.sendMessage("Removed potion effects") return True
def onCommandItemname(sender,args): if len(args) == 0: sender.sendMessage(''.join([color("c"),"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 False 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" and len(args) > 0: if len(args) < 2: Bukkit.dispatchCommand(sender,"e") else: Bukkit.dispatchCommand(sender,''.join(["e ",args[1]])) return True if len(args) < 3: sender.sendMessage(''.join([color("c"),"You must have the correct amount of arguments -",color("6")," /eff [effect] [power] [duration]"])) return False for i in range(1,2): if args[i].isdigit() == False: sender.sendMessage(''.join([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: sender.sendMessage(''.join([color("c"),"Invalid player"])) return False else: receiver = sender receiver.addPotionEffect(PotionEffect(eval(''.join(["PotionEffectType.",args[0]])), int(args[2]), (int(args[1])-1))) return True
def onCommandFoodfight(sender,args): if len(args) == 0: sender.sendMessage(''.join([color("c"),"/slap [Player] [Thing]"])) return False receiver = Bukkit.getPlayer(args[0]) if len(args) == 2: item = args[1] else: item = 'large trout' material = Material.matchMaterial(args[1]) if receiver == None: sender.sendMessage(''.join([color('c'),'No such player.'])) return False if receiver == sender: receiverName = 'themself' else: reveiverName = receiver.getName() if item[0] in vowels: Bukkit.broadcastMessage(''.join([color("5"),sender.getName(),color("c")," slapped ",color("5"),receiverName,color("c")," about a bit with an ",color("5"),item])) else: Bukkit.broadcastMessage(''.join([color("5"),sender.getName(),color("c")," slapped ",color("5"),receiverName,color("c")," about a bit with a ",color("5"),item])) if random.randint(0,1): receiver.addPotionEffect(PotionEffect(PotionEffectType.CONFUSION, 160, 3, True)) else: receiver.addPotionEffect(PotionEffect(PotionEffectType.BLINDNESS, 20, 3, True)) if material != None: sudo(' '.join(['give',receiver.getName(),material.getId()])) return True
def on_toggle_message_command(sender, command, label, args): if not sender.hasPermission(permission) or not is_player(sender): noperm(sender) return True plugin_header(sender, "Private Message Toggle") uuid = uid(sender) if len(args) > 0: if len(args) > 1: msg(sender, "&cToo many arguments!") return True target = Bukkit.getPlayer(args[0]) if target: toggle_dict[uuid] = uid(target) msg(sender, "&2Enabled toggle so that you're now sending only to %s &2by default" % target.getDisplayName()) else: msg(sender, "&cThat player could not be found") elif uuid in toggle_dict: del toggle_dict[uuid] msg(sender, "&2Disabled toggle successfully") else: msg(sender, "&cExpected a player as argument") return True
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
def event_resident_add(self, event): residentJoined = event.getResident() if residentJoined is None: return town = event.getTown() if town is None: return player = Bukkit.getPlayer(residentJoined.getName()) if (player is None) or (not player.isOnline()) or player.hasPermission(PERM_ADMIN): return hasResidentsInTown = False findedResident = False playerInTown = None for resTown in town.getResidents(): if (resTown == residentJoined): continue hasResidentsInTown = True if resTown.isNPC(): continue playerInTown = Bukkit.getPlayer(resTown.getName()) if (playerInTown is None) or (not playerInTown.isOnline()) or (playerInTown.hasPermission(PERM_ADMIN)): # Если игрок не в сети, или этот игрок Админ, тогда продолжаем поиск. # Из-за админа мы не можем заинвайтить игрока в город, ибо может начаться каша в городе! continue findedResident = True break # Если событие вызывается когда игрок создает город, # то надо игнорировать все проверки и просто ничего не делать if not hasResidentsInTown: return needRemove = False if findedResident: isTownHero = playerInTown.hasPermission(PERM_HEROES) isTownOutcast = playerInTown.hasPermission(PERM_OUTCAST) isResHero = player.hasPermission(PERM_HEROES) isResOutcast = player.hasPermission(PERM_OUTCAST) isResAdmin = player.hasPermission(PERM_ADMIN) # print "isTownHero: %s, isTownOutcast: %s, isResHero: %s, isResOutcast: %s, isResAdmin: %s" % (isTownHero, isTownOutcast, isResHero, isResOutcast, isResAdmin) isCorrect = isResAdmin or (isTownHero and isResHero) or (isTownOutcast and isResOutcast) if not isCorrect: needRemove = True player.sendMessage(u"%sВы не можете вступить в город противоположной фракции." % ChatColor.RED) else: needRemove = True player.sendMessage(u"%sВ данный момент в городе нет игроков в онлайн! Подождите пока кто-нибудь появится онлайн." % ChatColor.RED) if needRemove: try: town.removeResident(residentJoined) except: pass
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