import plugins, packetFactory
import data.clients

@plugins.onConnection
def checkConfig(user):
	if user.playerId in data.clients.connectedClients:
		clientPrefs = data.clients.connectedClients[user.playerId].getPrefs()
		if 'globalChat' not in clientPrefs:
			clientPrefs['globalChat'] = True
		data.clients.connectedClients[user.playerId].setPrefs(clientPrefs)

@plugins.commandHook("gon")
def enable(context, params):
	prefs = data.clients.connectedClients[context.playerId].getPrefs()
	prefs['globalChat'] = True
	context.sendCryptoPacket(packetFactory.ChatPacket(context.playerId, "[GlobalChat] Global chat enabled for this session.").build())
	data.clients.connectedClients[context.playerId].setPrefs(prefs)

@plugins.commandHook("goff")
def disable(context, params):
	prefs = data.clients.connectedClients[context.playerId].getPrefs()
	prefs['globalChat'] = False
	context.sendCryptoPacket(packetFactory.ChatPacket(context.playerId, "[GlobalChat] Global chat disabled for this session.").build())
	data.clients.connectedClients[context.playerId].setPrefs(prefs)

@plugins.commandHook("g")
def chat(context, params):
	if not data.clients.connectedClients[context.playerId].getPrefs()['globalChat']:
		context.sendCryptoPacket(packetFactory.ChatPacket(context.playerId, "[GlobalChat] You do not have global chat enabled, and can not send a global message.").build())
		return
import plugins, packetFactory
import data.clients

@plugins.onConnectionHook
def checkConfig(user):
	if user.playerId in data.clients.connectedClients:
		clientPrefs = data.clients.connectedClients[user.playerId].getPrefs()
		if 'globalChat' not in clientPrefs:
			clientPrefs['globalChat'] = True
		data.clients.connectedClients[user.playerId].setPrefs(clientPrefs)

@plugins.commandHook("gon")
def enable(context, params):
	prefs = data.clients.connectedClients[context.playerId].getPrefs()
	prefs['globalChat'] = True
	context.sendCryptoPacket(packetFactory.ChatPacket(context.playerId, "[GlobalChat] Global chat enabled for this session.").build())
	data.clients.connectedClients[context.playerId].setPrefs(prefs)

@plugins.commandHook("goff")
def disable(context, params):
	prefs = data.clients.connectedClients[context.playerId].getPrefs()
	prefs['globalChat'] = False
	context.sendCryptoPacket(packetFactory.ChatPacket(context.playerId, "[GlobalChat] Global chat disabled for this session.").build())
	data.clients.connectedClients[context.playerId].setPrefs(prefs)

@plugins.commandHook("g")
def chat(context, params):
	if not data.clients.connectedClients[context.playerId].getPrefs()['globalChat']:
		context.sendCryptoPacket(packetFactory.ChatPacket(context.playerId, "[GlobalChat] You do not have global chat enabled, and can not send a global message.").build())
		return

Use hook, not the list as decorator.