Adding tabnames, updating main #34
31
tabnames.py
31
tabnames.py
@ -1,6 +1,4 @@
|
|||||||
import org.bukkit as bukkit
|
|
||||||
from helpers import *
|
from helpers import *
|
||||||
from org.bukkit import *
|
|
||||||
|
|
||||||
tabnames_version = "v1.0.0"
|
tabnames_version = "v1.0.0"
|
||||||
|
|
||||||
@ -12,20 +10,29 @@ tabnames_version = "v1.0.0"
|
|||||||
# #
|
# #
|
||||||
##############################################################
|
##############################################################
|
||||||
|
|
||||||
ranks = ["visitor", "member", "builder", "trusted", "modintraining", "mod", "admin", "breaker"]
|
ranks = ["visitor", "member", "builder", "trusted", "modintraining", "mod", "admin"]
|
||||||
prefixes = {"admin":"a", "mod":"b", "modintraining":"c", "trusted":"d", "builder":"e", "member":"f","visitor":"g"}
|
prefixes = {"admin":"a", "mod":"b", "modintraining":"c", "trusted":"d", "builder":"e", "member":"f","visitor":"g"}
|
||||||
|
|
||||||
@hook.event("player.PlayerJoinEvent", "low")
|
@hook.event("player.PlayerJoinEvent", "low")
|
||||||
def on_player_join(event):
|
def on_player_join(event):
|
||||||
scoreboard_team = prefix(get_Rank(event.getPlayer()))
|
player = event.getPlayer()
|
||||||
bukkit.Bukkit.getServer().dispatchCommand(bukkit.Bukkit.getServer().getConsoleSender(),
|
team = get_team(player)
|
||||||
"scoreboard teams join " + scoreboard_team + " " + event.getPlayer().getName())
|
if team:
|
||||||
|
cmd = "scoreboard teams join %s %s" % (team, player.getName())
|
||||||
|
server.dispatchCommand(server.getConsoleSender(), cmd)
|
||||||
|
|
||||||
def get_Rank(player):
|
def get_rank(player):
|
||||||
for i in range(0, len(ranks) - 1):
|
player_rank = None
|
||||||
if not player.hasPermission("group." + ranks[i]):
|
for rank in ranks:
|
||||||
|
if not player.hasPermission("group.%s" % rank):
|
||||||
break
|
break
|
||||||
return ranks[i-1]
|
player_rank = rank
|
||||||
|
if not player_rank:
|
||||||
|
warn("Couldn't find rank for player %s" % player.getName())
|
||||||
|
return player_rank
|
||||||
|
|
||||||
def prefix(rank):
|
def get_team(player):
|
||||||
return prefixes.get(rank) + "_" + rank
|
rank = get_rank(player)
|
||||||
|
if rank:
|
||||||
|
prefix = prefixes.get(rank)
|
||||||
|
return "_".join([prefix, rank])
|
Reference in New Issue
Block a user