aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/PlayerTeam.cpp
blob: 608cb36b052e02753423505a89ade8f3f8066c6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include "stdafx.h"
#include "net.minecraft.world.scores.h"
#include "PlayerTeam.h"

PlayerTeam::PlayerTeam(Scoreboard *scoreboard, const wstring &name)
{
	this->scoreboard = scoreboard;
	this->name = name;
	displayName = name;

	prefix = L"";
	suffix = L"";
	allowFriendlyFire = true;
	seeFriendlyInvisibles = true;
}

Scoreboard *PlayerTeam::getScoreboard()
{
	return scoreboard;
}

wstring PlayerTeam::getName()
{
	return name;
}

wstring PlayerTeam::getDisplayName()
{
	return displayName;
}

void PlayerTeam::setDisplayName(const wstring &displayName)
{
	//if (displayName == null) throw new IllegalArgumentException("Name cannot be null");
	this->displayName = displayName;
	scoreboard->onTeamChanged(this);
}

unordered_set<wstring> *PlayerTeam::getPlayers()
{
	return &players;
}

wstring PlayerTeam::getPrefix()
{
	return prefix;
}

void PlayerTeam::setPrefix(const wstring &prefix)
{
	//if (prefix == null) throw new IllegalArgumentException("Prefix cannot be null");
	this->prefix = prefix;
	scoreboard->onTeamChanged(this);
}

wstring PlayerTeam::getSuffix()
{
	return suffix;
}

void PlayerTeam::setSuffix(const wstring &suffix)
{
	//if (suffix == null) throw new IllegalArgumentException("Suffix cannot be null");
	this->suffix = suffix;
	scoreboard->onTeamChanged(this);
}

wstring PlayerTeam::getFormattedName(const wstring &teamMemberName)
{
	return getPrefix() + teamMemberName + getSuffix();
}

wstring PlayerTeam::formatNameForTeam(PlayerTeam *team)
{
	return formatNameForTeam(team, team->getDisplayName());
}

wstring PlayerTeam::formatNameForTeam(Team *team, const wstring &name)
{
	if (team == nullptr) return name;
	return team->getFormattedName(name);
}

bool PlayerTeam::isAllowFriendlyFire()
{
	return allowFriendlyFire;
}

void PlayerTeam::setAllowFriendlyFire(bool allowFriendlyFire)
{
	this->allowFriendlyFire = allowFriendlyFire;
	scoreboard->onTeamChanged(this);
}

bool PlayerTeam::canSeeFriendlyInvisibles()
{
	return seeFriendlyInvisibles;
}

void PlayerTeam::setSeeFriendlyInvisibles(bool seeFriendlyInvisibles)
{
	this->seeFriendlyInvisibles = seeFriendlyInvisibles;
	scoreboard->onTeamChanged(this);
}

int PlayerTeam::packOptions()
{
	int result = 0;

	if (isAllowFriendlyFire()) result |= 1 << BIT_FRIENDLY_FIRE;
	if (canSeeFriendlyInvisibles()) result |= 1 << BIT_SEE_INVISIBLES;

	return result;
}

void PlayerTeam::unpackOptions(int options)
{
	setAllowFriendlyFire((options & (1 << BIT_FRIENDLY_FIRE)) > 0);
	setSeeFriendlyInvisibles((options & (1 << BIT_SEE_INVISIBLES)) > 0);
}