Commits
Parker Hawke authored and md_5 committed a94277a18bf
19 19 | super(scoreboard); |
20 20 | this.objective = objective; |
21 21 | this.criteria = CraftCriteria.getFromNMS(objective); |
22 22 | } |
23 23 | |
24 24 | ScoreboardObjective getHandle() { |
25 25 | return objective; |
26 26 | } |
27 27 | |
28 28 | |
29 - | public String getName() throws IllegalStateException { |
29 + | public String getName() { |
30 30 | checkState(); |
31 31 | |
32 32 | return objective.getName(); |
33 33 | } |
34 34 | |
35 35 | |
36 - | public String getDisplayName() throws IllegalStateException { |
36 + | public String getDisplayName() { |
37 37 | checkState(); |
38 38 | |
39 39 | return CraftChatMessage.fromComponent(objective.getDisplayName()); |
40 40 | } |
41 41 | |
42 42 | |
43 - | public void setDisplayName(String displayName) throws IllegalStateException, IllegalArgumentException { |
43 + | public void setDisplayName(String displayName) { |
44 44 | Preconditions.checkArgument(displayName != null, "Display name cannot be null"); |
45 - | Preconditions.checkArgument(displayName.length() <= 128, "Display name '" + displayName + "' is longer than the limit of 128 characters"); |
46 45 | checkState(); |
47 46 | |
48 47 | objective.setDisplayName(CraftChatMessage.fromString(displayName)[0]); // SPIGOT-4112: not nullable |
49 48 | } |
50 49 | |
51 50 | |
52 - | public String getCriteria() throws IllegalStateException { |
51 + | public String getCriteria() { |
53 52 | checkState(); |
54 53 | |
55 54 | return criteria.bukkitName; |
56 55 | } |
57 56 | |
58 57 | |
59 - | public Criteria getTrackedCriteria() throws IllegalStateException { |
58 + | public Criteria getTrackedCriteria() { |
60 59 | checkState(); |
61 60 | |
62 61 | return criteria; |
63 62 | } |
64 63 | |
65 64 | |
66 - | public boolean isModifiable() throws IllegalStateException { |
65 + | public boolean isModifiable() { |
67 66 | checkState(); |
68 67 | |
69 68 | return !criteria.criteria.isReadOnly(); |
70 69 | } |
71 70 | |
72 71 | |
73 - | public void setDisplaySlot(DisplaySlot slot) throws IllegalStateException { |
72 + | public void setDisplaySlot(DisplaySlot slot) { |
74 73 | CraftScoreboard scoreboard = checkState(); |
75 74 | Scoreboard board = scoreboard.board; |
76 75 | ScoreboardObjective objective = this.objective; |
77 76 | |
78 77 | for (int i = 0; i < CraftScoreboardTranslations.MAX_DISPLAY_SLOT; i++) { |
79 78 | if (board.getDisplayObjective(i) == objective) { |
80 79 | board.setDisplayObjective(i, null); |
81 80 | } |
82 81 | } |
83 82 | if (slot != null) { |
84 83 | int slotNumber = CraftScoreboardTranslations.fromBukkitSlot(slot); |
85 84 | board.setDisplayObjective(slotNumber, getHandle()); |
86 85 | } |
87 86 | } |
88 87 | |
89 88 | |
90 - | public DisplaySlot getDisplaySlot() throws IllegalStateException { |
89 + | public DisplaySlot getDisplaySlot() { |
91 90 | CraftScoreboard scoreboard = checkState(); |
92 91 | Scoreboard board = scoreboard.board; |
93 92 | ScoreboardObjective objective = this.objective; |
94 93 | |
95 94 | for (int i = 0; i < CraftScoreboardTranslations.MAX_DISPLAY_SLOT; i++) { |
96 95 | if (board.getDisplayObjective(i) == objective) { |
97 96 | return CraftScoreboardTranslations.toBukkitSlot(i); |
98 97 | } |
99 98 | } |
100 99 | return null; |
101 100 | } |
102 101 | |
103 102 | |
104 - | public void setRenderType(RenderType renderType) throws IllegalStateException { |
103 + | public void setRenderType(RenderType renderType) { |
105 104 | Preconditions.checkArgument(renderType != null, "RenderType cannot be null"); |
106 105 | checkState(); |
107 106 | |
108 107 | this.objective.setRenderType(CraftScoreboardTranslations.fromBukkitRender(renderType)); |
109 108 | } |
110 109 | |
111 110 | |
112 - | public RenderType getRenderType() throws IllegalStateException { |
111 + | public RenderType getRenderType() { |
113 112 | checkState(); |
114 113 | |
115 114 | return CraftScoreboardTranslations.toBukkitRender(this.objective.getRenderType()); |
116 115 | } |
117 116 | |
118 117 | |
119 - | public Score getScore(OfflinePlayer player) throws IllegalArgumentException, IllegalStateException { |
118 + | public Score getScore(OfflinePlayer player) { |
120 119 | Preconditions.checkArgument(player != null, "Player cannot be null"); |
121 120 | checkState(); |
122 121 | |
123 122 | return new CraftScore(this, player.getName()); |
124 123 | } |
125 124 | |
126 125 | |
127 - | public Score getScore(String entry) throws IllegalArgumentException, IllegalStateException { |
126 + | public Score getScore(String entry) { |
128 127 | Preconditions.checkArgument(entry != null, "Entry cannot be null"); |
129 128 | Preconditions.checkArgument(entry.length() <= Short.MAX_VALUE, "Score '" + entry + "' is longer than the limit of 32767 characters"); |
130 129 | checkState(); |
131 130 | |
132 131 | return new CraftScore(this, entry); |
133 132 | } |
134 133 | |
135 134 | |
136 - | public void unregister() throws IllegalStateException { |
135 + | public void unregister() { |
137 136 | CraftScoreboard scoreboard = checkState(); |
138 137 | |
139 138 | scoreboard.board.removeObjective(objective); |
140 139 | } |
141 140 | |
142 141 | |
143 - | CraftScoreboard checkState() throws IllegalStateException { |
142 + | CraftScoreboard checkState() { |
144 143 | Preconditions.checkState(getScoreboard().board.getObjective(objective.getName()) != null, "Unregistered scoreboard component"); |
145 144 | |
146 145 | return getScoreboard(); |
147 146 | } |
148 147 | |
149 148 | |
150 149 | public int hashCode() { |
151 150 | int hash = 7; |
152 151 | hash = 31 * hash + (this.objective != null ? this.objective.hashCode() : 0); |
153 152 | return hash; |