Skip to content

Commit a981c38

Browse files
committed
small cleanup
1 parent 57e5ecf commit a981c38

File tree

2 files changed

+66
-52
lines changed

2 files changed

+66
-52
lines changed

src/main/java/com/fibermc/essentialcommands/commands/joinpoints/JoinpointException.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ abstract class JoinpointException extends RuntimeException {
1010

1111
public abstract Text message(ECText ecText);
1212

13-
private static abstract class Tp extends JoinpointException {
13+
private abstract static class Tp extends JoinpointException {
1414
private final String ownerName;
1515

16-
public Tp(String ownerName) {
16+
Tp(String ownerName) {
1717
this.ownerName = ownerName;
1818
}
1919

@@ -22,10 +22,10 @@ public String getOwnerName() {
2222
}
2323
}
2424

25-
private static abstract class WithName extends Tp {
25+
private abstract static class WithName extends Tp {
2626
private final String joinpointName;
2727

28-
public WithName(String joinpointName, String ownerName) {
28+
WithName(String joinpointName, String ownerName) {
2929
super(ownerName);
3030
this.joinpointName = joinpointName;
3131
}
@@ -36,7 +36,7 @@ public String getJoinpointName() {
3636
}
3737

3838
static final class TpNotFound extends WithName {
39-
public TpNotFound(String joinpointName, String ownerName) {
39+
TpNotFound(String joinpointName, String ownerName) {
4040
super(joinpointName, ownerName);
4141
}
4242

@@ -52,7 +52,7 @@ public Text message(ECText ecText) {
5252
}
5353

5454
static final class TpNoAccess extends WithName {
55-
public TpNoAccess(String joinpointName, String ownerName) {
55+
TpNoAccess(String joinpointName, String ownerName) {
5656
super(joinpointName, ownerName);
5757
}
5858

@@ -68,7 +68,7 @@ public Text message(ECText ecText) {
6868
}
6969

7070
static final class OwnerNotFound extends Tp {
71-
public OwnerNotFound(String ownerName) {
71+
OwnerNotFound(String ownerName) {
7272
super(ownerName);
7373
}
7474

@@ -82,10 +82,10 @@ public Text message(ECText ecText) {
8282
}
8383
}
8484

85-
static abstract class Share extends JoinpointException {
85+
abstract static class Share extends JoinpointException {
8686
private final String joinpointName;
8787

88-
public Share(String joinpointName) {
88+
Share(String joinpointName) {
8989
this.joinpointName = joinpointName;
9090
}
9191

@@ -95,7 +95,7 @@ public String getJoinpointName() {
9595
}
9696

9797
static final class NotFound extends Share {
98-
public NotFound(String joinpointName) {
98+
NotFound(String joinpointName) {
9999
super(joinpointName);
100100
}
101101

@@ -110,7 +110,7 @@ public Text message(ECText ecText) {
110110
}
111111

112112
static final class AlreadyGlobal extends Share {
113-
public AlreadyGlobal(String joinpointName) {
113+
AlreadyGlobal(String joinpointName) {
114114
super(joinpointName);
115115
}
116116

@@ -125,7 +125,7 @@ public Text message(ECText ecText) {
125125
}
126126

127127
static final class NoNewPlayers extends Share {
128-
public NoNewPlayers(String joinpointName) {
128+
NoNewPlayers(String joinpointName) {
129129
super(joinpointName);
130130
}
131131

@@ -139,7 +139,7 @@ public Text message(ECText ecText) {
139139
}
140140

141141
static final class PlayersNotShared extends Share {
142-
public PlayersNotShared(String joinpointName) {
142+
PlayersNotShared(String joinpointName) {
143143
super(joinpointName);
144144
}
145145

@@ -153,7 +153,7 @@ public Text message(ECText ecText) {
153153
}
154154

155155
static final class CannotClearGlobal extends Share {
156-
public CannotClearGlobal(String joinpointName) {
156+
CannotClearGlobal(String joinpointName) {
157157
super(joinpointName);
158158
}
159159

@@ -167,10 +167,10 @@ public Text message(ECText ecText) {
167167
}
168168
}
169169

170-
static abstract class Set extends JoinpointException {
170+
abstract static class Set extends JoinpointException {
171171
private final String joinpointName;
172172

173-
public Set(String joinpointName) {
173+
Set(String joinpointName) {
174174
this.joinpointName = joinpointName;
175175
}
176176

@@ -179,7 +179,7 @@ public String getJoinpointName() {
179179
}
180180

181181
static final class DeleteNotFound extends Set {
182-
public DeleteNotFound(String joinpointName) {
182+
DeleteNotFound(String joinpointName) {
183183
super(joinpointName);
184184
}
185185

@@ -194,7 +194,7 @@ public Text message(ECText ecText) {
194194
}
195195

196196
static final class DeleteGeneric extends Set {
197-
public DeleteGeneric(String joinpointName) {
197+
DeleteGeneric(String joinpointName) {
198198
super(joinpointName);
199199
}
200200

@@ -213,7 +213,7 @@ static final class MaxPointsExceeded extends Set {
213213
private final int current;
214214
private final JoinpointLimit.JoinpointType limitType;
215215

216-
public MaxPointsExceeded(String joinpointName, int max, int current, JoinpointLimit.JoinpointType limitType) {
216+
MaxPointsExceeded(String joinpointName, int max, int current, JoinpointLimit.JoinpointType limitType) {
217217
super(joinpointName);
218218
this.max = max;
219219
this.current = current;

src/main/java/com/fibermc/essentialcommands/commands/joinpoints/JoinpointListCommand.java

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -85,36 +85,38 @@ private int exec(ServerPlayerEntity senderPlayer, FilterType filter) {
8585
return null;
8686
}
8787

88-
// Send header message
89-
String headerKey = switch (filter) {
90-
case OWNED -> "cmd.joinpoint.list.header.owned";
91-
case SHARED_WITH -> "cmd.joinpoint.list.header.shared_with";
92-
case GLOBAL -> "cmd.joinpoint.list.header.global";
93-
case ALL -> "cmd.joinpoint.list.header.all";
94-
};
95-
playerData.sendMessage(headerKey, Text.literal(String.valueOf(filteredJoinpoints.size())));
88+
{ // Send header message
89+
String headerKey = switch (filter) {
90+
case OWNED -> "cmd.joinpoint.list.header.owned";
91+
case SHARED_WITH -> "cmd.joinpoint.list.header.shared_with";
92+
case GLOBAL -> "cmd.joinpoint.list.header.global";
93+
case ALL -> "cmd.joinpoint.list.header.all";
94+
};
95+
playerData.sendMessage(headerKey, Text.literal(String.valueOf(filteredJoinpoints.size())));
96+
}
9697

9798
// Send each joinpoint with details
9899
var ecText = ECText.access(senderPlayer);
99100
for (JoinpointEntry entry : filteredJoinpoints) {
100101
MutableText message = Text.empty();
101102

102103
// Joinpoint name (clickable for teleport)
103-
MutableText nameText = ecText.accent(entry.joinpoint.getName())
104-
.styled(style -> style
105-
.withClickEvent(new ClickEvent.SuggestCommand(
106-
// right now I've removed this quick tp due to it getting prioritized over the other one
107-
// in command suggestions :/
108-
// entry.isOwned
109-
// ? "/joinpoint tp " + entry.joinpoint.getName()
110-
// :
104+
message.append("• ").append(
105+
ecText
106+
.accent(entry.joinpoint.getName())
107+
.styled(style -> style
108+
.withClickEvent(new ClickEvent.SuggestCommand(
109+
// right now I've removed this quick tp due to it getting prioritized over the other one
110+
// in command suggestions :/
111+
// entry.isOwned
112+
// ? "/joinpoint tp " + entry.joinpoint.getName()
113+
// :
111114
"/joinpoint tp " + entry.ownerName + " " + entry.joinpoint.getName()
112-
))
113-
.withHoverEvent(new HoverEvent.ShowText(
114-
Text.literal("Click to suggest teleport command")
115-
)));
116-
117-
message.append("• ").append(nameText);
115+
))
116+
.withHoverEvent(new HoverEvent.ShowText(
117+
Text.literal("Click to suggest teleport command")
118+
)))
119+
);
118120

119121
// Add type indicators
120122
if (entry.joinpoint.isGlobal()) {
@@ -156,10 +158,12 @@ private int exec(ServerPlayerEntity senderPlayer, FilterType filter) {
156158
return SINGLE_SUCCESS;
157159
}
158160

159-
private List<JoinpointEntry> filterJoinpointsAsync(List<JoinpointDatabase.JoinpointLocationWithOwnerName> accessibleJoinpoints,
160-
UUID playerUuid,
161-
FilterType filter,
162-
JoinpointDatabase database) {
161+
private List<JoinpointEntry> filterJoinpointsAsync(
162+
List<JoinpointDatabase.JoinpointLocationWithOwnerName> accessibleJoinpoints,
163+
UUID playerUuid,
164+
FilterType filter,
165+
JoinpointDatabase database)
166+
{
163167
List<JoinpointEntry> result = new ArrayList<>();
164168

165169
for (var joinpoint : accessibleJoinpoints) {
@@ -196,15 +200,19 @@ private List<JoinpointEntry> filterJoinpointsAsync(List<JoinpointDatabase.Joinpo
196200
return result;
197201
}
198202

199-
static void getSharedWithNames(JoinpointDatabase database, JoinpointLocation joinpoint, Set<String> sharedWithNames) {
203+
static void getSharedWithNames(
204+
JoinpointDatabase database,
205+
JoinpointLocation joinpoint,
206+
Set<String> sharedWithNames
207+
) {
200208
var cachedNames = database.getCachedNamesForUuidsAsync(joinpoint.getSharedWith()).join();
201209
for (UUID uuid : joinpoint.getSharedWith()) {
202210
String name = cachedNames.get(uuid);
203-
if (name != null) {
204-
sharedWithNames.add(name);
205-
} else {
206-
sharedWithNames.add(uuid.toString().substring(0, 8) + "...");
207-
}
211+
sharedWithNames.add(
212+
name != null
213+
? name
214+
: uuid.toString().substring(0, 8) + "..."
215+
);
208216
}
209217
}
210218

@@ -215,7 +223,13 @@ private static class JoinpointEntry {
215223
final Text ownerDisplayName;
216224
final Set<String> sharedWith;
217225

218-
JoinpointEntry(JoinpointLocation joinpoint, boolean isOwned, String ownerName, Text ownerDisplayName, Set<String> sharedWith) {
226+
JoinpointEntry(
227+
JoinpointLocation joinpoint,
228+
boolean isOwned,
229+
String ownerName,
230+
Text ownerDisplayName,
231+
Set<String> sharedWith
232+
) {
219233
this.joinpoint = joinpoint;
220234
this.isOwned = isOwned;
221235
this.ownerName = ownerName;

0 commit comments

Comments
 (0)