Example #1
0
def uncaught_command(message, user, command):
	if command in MC_COMMANDS or user.username in ops():
		return False # Do not drop packet
	if user.username in ops() and command in ('ban','pardon'):
		tell(user, 'Please use the whitetree tools for bans: /whitetree ops')
		return True
	tell(user, "Bad command: %s" % command)
	return True # Drop packet
Example #2
0
def uncaught_command(message, user, command):
	for mc_cmd in MC_COMMANDS:
		if command.startswith(mc_cmd):
			return False # Do not drop packet
	if user.username in ops():
		tell(user, "Warning: I don't recognise %s" % message)
		return False
	tell(user, "Bad command: %s" % command)
	return True # Drop packet
Example #3
0
def zoneinfo(message, user, name):
	name = name.strip('"')

	try:
		zone = get_zones()[name]
	except KeyError:
		tell(user, "That zone doesn't exist!")
		return
	if not controls_zone(user.username, zone) and not user.username in ops():
		tell(user, "That isn't your zone.")
		return

	keys = ['name','creator','confirmed']
	for key in keys:
		if key in zone:
			tell(user, "%s: %s" % (key, zone[key]))

	keys.append('bounds_info')
	def dim_to_name(dim):
		try:
			return {-1: '(Nether)', 0: '(Overworld)', 1:'(End)'}[dim]
		except KeyError:
			return ""
	def tell_bounds(style, *args, **kwargs):
		indent = kwargs.pop("indent",0)
		indent_str = "__" * indent
		if style == 'cube':
			dim, point1, point2 = args
			tell(user, indent_str + "Cube in dim%d%s from (%.2f,%.2f,%.2f) to (%.2f,%.2f,%.2f)" % ((dim, dim_to_name(dim)) + tuple(point1) + tuple(point2)))
		elif style == 'cylinder':
			dim, base, radius, height = args
			tell(user, indent_str + "Cylinder in dim%d%s from (%.2f,%.2f,%.2f) to radius %.2f and height %.2f" % ((dim, dim_to_name(dim)) + tuple(base) + (radius, height)))
		elif style == 'union':
			tell(user, indent_str + "Union of regions:")
			for more_info in args:
				tell_bounds(*more_info, indent=indent+1)
		else:
			tell(user, indent_str + "Unknown region")
	tell_bounds(*zone['bounds_info'])

	if 'acls' in zone:
		keys.append('acls')
		tell(user, "acls:")
		for name in zone['acls']:
			if name == 'EVERYONE':
				continue
			tell(user, "__%s: %s" % (name, ",".join(zone['acls'][name])))
		tell(user, "__Everyone else: %s" % ",".join(zone['acls']['EVERYONE']))

	for key in zone:
		if key in keys:
			continue
		tell(user, "%s: %s" % (key, zone[key]))
Example #4
0
def zonedestroy(message, user, name):
	name = name.strip('"')

	try:
		zone = get_zones()[name]
	except KeyError:
		tell(user, "That zone doesn't exist!")
		return
	if not controls_zone(user.username, zone) and not user.username in ops():
		tell(user, "That isn't your zone.")
	get_zones().pop(name)
	tell(user, "Zone deleted.")
Example #5
0
def make_zone(user, name, bounds_info):
	zone = new_zone(name, bounds_info, user.username, confirmed=False)
	if zone is None:
		tell(user, "An error occurred while creating the zone. Try again or call an op.")
	else:
		tell(user, "Zone %s created. Exiting menu." % name)
		if user in ops():
			zone['confirmed'] = True
			tell(user, "Zone auto-confirmed for ops.")
		else:
			tell(user, "You will need to get your zone approved by an op\n"
			           "for plot protection to work.")
Example #6
0
def on_packet(packet, user, to_server):
    if packet.name() == 'Chat message':
        #Highlight admin names in red
        if not to_server:
            for op in ops():
                #insert op color flag before name and normal color flag after name
                packet.data['text'] = packet.data['text'].replace(op, opColor + op + color('white'))
            packet.data['text'] = packet.data['text'].replace(user.username, userColor + user.username + color('white'))
                
            #replace 'bitblitz' with developer name 'Sleepy Paradox'
            packet.data['text'] = packet.data['text'].replace(u'bitblitz', u'Sleepy Paradox')
    #return edited packet
    return packet
Example #7
0
def on_packet(packet, user_obj, to_server):
	if packet.name() == 'Chat message' and not to_server:
		prefs = users.get(user_obj.username, defaults)
		offlines = dict([(user, prefs['inactive']) for user in all_users()])
		onlines = dict([(user, prefs['active']) for user in active_users()])
		ops_dict = dict([(user, prefs['ops']) for user in ops()])
		player = {user_obj.username: prefs['me']}
		names = {}
		names.update(offlines)
		names.update(onlines)
		names.update(ops_dict)
		names.update(player)
		packet.data['text'] = prefs['all'] + packet.data['text']
		for name in names:
			packet.data['text'] = packet.data['text'].replace(name, names[name] + name + prefs['all'])
	return packet
Example #8
0
def on_packet(packet, user_obj, to_server):
	if packet.name() == 'Chat message' and not to_server:
		prefs = users.get(user_obj.username, defaults)
		offlines = dict([(user, prefs['inactive']) for user in all_users()])
		onlines = dict([(user, prefs['active']) for user in active_users()])
		ops_dict = dict([(user, prefs['ops']) for user in ops()])
		player = {user_obj.username: prefs['me']}
		names = {}
		names.update(offlines)
		names.update(onlines)
		names.update(ops_dict)
		names.update(player)
		s = prefs['all'] + packet.data['text']
		for name in names:
			i = 0
			while i < len(s):
				if s[i:i+len(name)].lower() == name:
					s = s[:i] + names[name] + s[i:i+len(name)] + prefs['all'] + s[i+len(name):]
					i += len(name)
				else:
					i += 1
		if len(s) <= MAX_CHAT_LENGTH: # Do nort replace if overlength
			packet.data['text'] = s
	return packet
Example #9
0
 def wrapped_fn(message, user, *args):
     if user.username not in helpers.ops():
         return False
     else:
         return fn(message, user, *args)
Example #10
0
	def wrapped_fn(message, user, zone, name, *args):

		zone_original = zone
		zone = zone.strip('"')
		if zone not in get_zones():
			tell(user, "Zone does not exist.")
			print zone
			return
		zone = get_zones()[zone]
		if 'acls' not in zone:
			tell(user, "Sorry, that zone does not appear to support ACLs.\n"
			           "You may need to contact an op to resolve this.")
			return

		if name != 'EVERYONE':
			name = name.lower()
			if name not in all_users() and name not in zone['acls']:
				tell(user, "Warning: %s is not a player known to this server.\n"
				           "If you have made a mistake, type:\n/acls %s clear %s" % (zone_original, name))

		if ADMIN not in zone['acls'].get(user.username, zone['acls']['EVERYONE']) and user.username not in ops():
			tell(user, "You do not have permission to modify ACLs for this zone. "
			           "If you have accidentially locked yourself out, please contact an op for assistance.")
			return

		return fn(message, user, zone, name, *args)