Adding tabnames, updating main #34
10
main.py
10
main.py
@ -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
37
nametags.py
Executable 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])
|
Reference in New Issue
Block a user