Adding tabnames, updating main #34

Merged
Pepich merged 5 commits from tabnames into dev 2016-02-15 00:34:56 +00:00
2 changed files with 43 additions and 4 deletions

10
main.py
View File

@ -89,7 +89,7 @@ shared["load_modules"] = [
# Servercontrol extension for telnet access to logs/AC
#"servercontrol",
# Script helper plugin
"scriptutils",
"scriptutils",
# Per-player notes
"tag",
# vanish toggle module - temporary fix
@ -98,10 +98,12 @@ shared["load_modules"] = [
"punishments",
# a simple replacement for the buggy essentials /vanish
"vanish",
# ip-tracking utility
"iptracker",
# ip-tracking utility - disabled as of instability
#"iptracker",
#server signs for everyone
"serversigns"
"serversigns",
# Makes player's names colored, sorts tab list by rank
"nametags"
]
shared["modules"] = {}
for module in shared["load_modules"]:

37
nametags.py Executable file
View File

@ -0,0 +1,37 @@
from helpers import *
##############################################################
# #
# This module automatically puts people in the corresponding #
# scoreboard team so that their name is colored properly and #
# tab will be nicely sorted. #
# #
##############################################################
ranks = ["visitor", "member", "builder", "trusted", "modintraining", "mod", "admin"]
# prefixes are used for sorting in the tab list
prefixes = {"admin":"a", "mod":"b", "modintraining":"c", "trusted":"d", "builder":"e", "member":"f","visitor":"g"}
@hook.event("player.PlayerJoinEvent", "low")
def on_player_join(event):
player = event.getPlayer()
team = get_team(player)
if team:
cmd = "scoreboard teams join %s %s" % (team, player.getName())
server.dispatchCommand(server.getConsoleSender(), cmd)
def get_rank(player):
player_rank = None
for rank in ranks:
if not player.hasPermission("group.%s" % rank):
break
player_rank = rank
if not player_rank:
warn("Couldn't find rank for player %s" % player.getName())
return player_rank
def get_team(player):
rank = get_rank(player)
if rank:
prefix = prefixes.get(rank)
return "_".join([prefix, rank])