def command(sender, cmd, label, args): if not sender.hasPermission(slave_perm): noperm(sender) return True if len(args) == 0 or (len(args) != 1 and args[0] == "list") or ( len(args) != 2 and args[0] == "rem") or (len(args) != 3 and args[0] == "add"): msg(sender, "&e-&a /miner add/rem/list <name> <amount>") return True if args[0] == "add": try: int(args[2]) except: msg(sender, "&cArgument <amount> is not a number") return True if args[0] == "list": if len(slaves) == 0: msg(sender, "&e-&a There are no people mining obsidian") return True for slave in slaves: msg( sender, "&e-&a %s: %s blocks" % (server.getOfflinePlayer( juuid(slave.get_uuid())).getName(), slave.get_blocks())) return True elif args[0] == "add": player = server.getOfflinePlayer(str(args[1])) if player.isOnline(): player.teleport(server.getWorld(punish_world).getSpawnLocation()) Slave(False, player, int(args[2])) save_slaves() msg( player, "&e-&a You have been punished, mine %s blocks of obsidian to get out!" % args[2]) msg( sender, "&e-&a Player %s has been added into punishments for %s blocks of obsidian" % (player.getName(), args[2])) else: msg(sender, "&cYou can only punish online players") return True elif args[0] == "rem": player = server.getOfflinePlayer(str(args[1])) if player.isOnline(): slave = get_slave(uid(player)) if slave != None: server.getPlayer(juuid(slave.get_uuid())).teleport( server.getWorld(spawn_world).getSpawnLocation()) slaves.remove(slave) save_slaves() else: msg(sender, "&e-&a Player not in punishments") else: msg(sender, "&cYou can only remove online players") return True else: msg(sender, "&e-&a /miner add/rem/list <name> <amount>") return True
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 on_chatgroup_command(sender, command, label, args): plugin_header(sender, "ChatGroups") sender_id = uid(sender) if len(args) == 1 and args[0] == "leave": if sender_id in groups.keys(): groupchat(sender, "left the group", True) group = groups[sender_id] del(groups[sender_id]) save_groups() else: msg(sender, "&aYou can't leave no group, derp!") elif len(args) == 1 and args[0] == "info": if sender_id in groups.keys(): group = groups[sender_id] msg(sender, "&aCurrent chatgroup: %s" % group) users = [user.getDisplayName() for user in [server.getPlayer(juuid(uuid)) for uuid, ugroup in groups.iteritems() if ugroup == group] if user] msg(sender, "&aUsers in this group:") msg(sender, "&a%s" % ", ".join(users)) else: msg(sender, "&aYou're in no chatgroup.") elif len(args) == 2 and args[0] == "join": groups[sender_id] = args[1] groupchat(sender, "joined the group", True) save_groups() msg(sender, "&aYour chatgroup is set to '%s'" % args[1]) msg(sender, "&aUse chat like '&e%s<message>' to send messages to this group." % get_key(sender_id)) elif len(args) == 1 and args[0] == "key": msg(sender, "&aYour chatgroup key is currently: '&c%s&a'" % get_key(sender_id)) else: msg(sender, "&e/chatgroup join <name>") msg(sender, "&e/chatgroup leave") msg(sender, "&e/chatgroup info") msg(sender, "&e/chatgroup key")
def update(self): self.blocks -= 1 if self.blocks <= 0: server.getPlayer(juuid(self.get_uuid())).teleport( server.getWorld(spawn_world).getSpawnLocation()) slaves.remove(self) save_slaves()
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 on_chatgroup_command(sender, command, label, args): plugin_header(sender, "ChatGroups") sender_id = uid(sender) if len(args) == 1 and args[0] == "leave": if sender_id in groups.keys(): groupchat(sender, "left the group", True) if sender in cg_toggle_list: cg_toggle_list.remove(p) group = groups[sender_id] del (groups[sender_id]) save_groups() else: msg(sender, "&aYou can't leave no group, derp!") elif len(args) == 1 and args[0] == "info": if sender_id in groups.keys(): group = groups[sender_id] msg(sender, "&aCurrent chatgroup: %s" % group) users = [ user.getDisplayName() for user in [ server.getPlayer(juuid(uuid)) for uuid, ugroup in groups.iteritems() if ugroup == group ] if user ] msg(sender, "&aUsers in this group:") msg(sender, "&a%s" % ", ".join(users)) else: msg(sender, "&aYou're in no chatgroup.") elif len(args) == 2 and args[0] == "join": groups[sender_id] = args[1] groupchat(sender, "joined the group", True) save_groups() msg(sender, "&aYour chatgroup is set to '%s'" % args[1]) msg( sender, "&aUse chat like '&e%s<message>' to send messages to this group." % get_key(sender_id)) elif len(args) == 1 and args[0] == "key": msg(sender, "&aYour chatgroup key is currently: '&c%s&a'" % get_key(sender_id)) elif len(args) == 1 and args[0] == "tpahere": if sender_id in groups.keys(): do_for_chatgroup(groups[sender_id], send_tpa_request, sender) msg(sender, "&aSent a tpahere request to all users in your chatgroup") else: msg(sender, "&cYou have to be in a chatgroup to do that") else: msg(sender, "&e/chatgroup join <name>") msg(sender, "&e/chatgroup leave") msg(sender, "&e/chatgroup info") msg(sender, "&e/chatgroup key") msg(sender, "&e/chatgroup tpahere")
def get_reporter(report): return server.getOfflinePlayer(juuid(report["uuid"]))
def retrieve_player(uuid_str): """ gets an offline player by UUID string the uuid MUST contain dashes """ return server.getOfflinePlayer(juuid(uuid_str))