19
19
20
20
public class PlayerPlaceholders {
21
21
public static void register () {
22
- Placeholders .register (new Identifier ("player" , "name" ), (ctx , arg ) -> {
22
+ Placeholders .register (Identifier . of ("player" , "name" ), (ctx , arg ) -> {
23
23
if (ctx .hasPlayer ()) {
24
24
return PlaceholderResult .value (ctx .player ().getName ());
25
25
} else if (ctx .hasGameProfile ()) {
@@ -29,7 +29,7 @@ public static void register() {
29
29
}
30
30
});
31
31
32
- Placeholders .register (new Identifier ("player" , "name_visual" ), (ctx , arg ) -> {
32
+ Placeholders .register (Identifier . of ("player" , "name_visual" ), (ctx , arg ) -> {
33
33
if (ctx .hasPlayer ()) {
34
34
return PlaceholderResult .value (GeneralUtils .removeHoverAndClick (ctx .player ().getName ()));
35
35
} else if (ctx .hasGameProfile ()) {
@@ -39,7 +39,7 @@ public static void register() {
39
39
}
40
40
});
41
41
42
- Placeholders .register (new Identifier ("player" , "name_unformatted" ), (ctx , arg ) -> {
42
+ Placeholders .register (Identifier . of ("player" , "name_unformatted" ), (ctx , arg ) -> {
43
43
if (ctx .hasPlayer ()) {
44
44
return PlaceholderResult .value (ctx .player ().getName ().getString ());
45
45
} else if (ctx .hasGameProfile ()) {
@@ -49,15 +49,15 @@ public static void register() {
49
49
}
50
50
});
51
51
52
- Placeholders .register (new Identifier ("player" , "ping" ), (ctx , arg ) -> {
52
+ Placeholders .register (Identifier . of ("player" , "ping" ), (ctx , arg ) -> {
53
53
if (ctx .hasPlayer ()) {
54
54
return PlaceholderResult .value (String .valueOf (ctx .player ().networkHandler .getLatency ()));
55
55
} else {
56
56
return PlaceholderResult .invalid ("No player!" );
57
57
}
58
58
});
59
59
60
- Placeholders .register (new Identifier ("player" , "ping_colored" ), (ctx , arg ) -> {
60
+ Placeholders .register (Identifier . of ("player" , "ping_colored" ), (ctx , arg ) -> {
61
61
if (ctx .hasPlayer ()) {
62
62
int x = ctx .player ().networkHandler .getLatency ();
63
63
return PlaceholderResult .value (Text .literal (String .valueOf (x )).formatted (x < 100 ? Formatting .GREEN : x < 200 ? Formatting .GOLD : Formatting .RED ));
@@ -66,7 +66,7 @@ public static void register() {
66
66
}
67
67
});
68
68
69
- Placeholders .register (new Identifier ("player" , "displayname" ), (ctx , arg ) -> {
69
+ Placeholders .register (Identifier . of ("player" , "displayname" ), (ctx , arg ) -> {
70
70
if (ctx .hasPlayer ()) {
71
71
return PlaceholderResult .value (ctx .player ().getDisplayName ());
72
72
} else if (ctx .hasGameProfile ()) {
@@ -76,9 +76,9 @@ public static void register() {
76
76
}
77
77
});
78
78
79
- Placeholders .register (new Identifier ("player" , "display_name" ), Placeholders .getPlaceholders ().get (new Identifier ("player" , "displayname" )));
79
+ Placeholders .register (Identifier . of ("player" , "display_name" ), Placeholders .getPlaceholders ().get (Identifier . of ("player" , "displayname" )));
80
80
81
- Placeholders .register (new Identifier ("player" , "displayname_visual" ), (ctx , arg ) -> {
81
+ Placeholders .register (Identifier . of ("player" , "displayname_visual" ), (ctx , arg ) -> {
82
82
if (ctx .hasPlayer ()) {
83
83
return PlaceholderResult .value (GeneralUtils .removeHoverAndClick (ctx .player ().getDisplayName ()));
84
84
} else if (ctx .hasGameProfile ()) {
@@ -88,9 +88,9 @@ public static void register() {
88
88
}
89
89
});
90
90
91
- Placeholders .register (new Identifier ("player" , "display_name_visual" ), Placeholders .getPlaceholders ().get (new Identifier ("player" , "displayname_visual" )));
91
+ Placeholders .register (Identifier . of ("player" , "display_name_visual" ), Placeholders .getPlaceholders ().get (Identifier . of ("player" , "displayname_visual" )));
92
92
93
- Placeholders .register (new Identifier ("player" , "displayname_unformatted" ), (ctx , arg ) -> {
93
+ Placeholders .register (Identifier . of ("player" , "displayname_unformatted" ), (ctx , arg ) -> {
94
94
if (ctx .hasPlayer ()) {
95
95
return PlaceholderResult .value (Text .literal (ctx .player ().getDisplayName ().getString ()));
96
96
} else if (ctx .hasGameProfile ()) {
@@ -99,9 +99,9 @@ public static void register() {
99
99
return PlaceholderResult .invalid ("No player!" );
100
100
}
101
101
});
102
- Placeholders .register (new Identifier ("player" , "display_name_unformatted" ), Placeholders .getPlaceholders ().get (new Identifier ("player" , "displayname_unformatted" )));
102
+ Placeholders .register (Identifier . of ("player" , "display_name_unformatted" ), Placeholders .getPlaceholders ().get (Identifier . of ("player" , "displayname_unformatted" )));
103
103
104
- Placeholders .register (new Identifier ("player" , "inventory_slot" ), (ctx , arg ) -> {
104
+ Placeholders .register (Identifier . of ("player" , "inventory_slot" ), (ctx , arg ) -> {
105
105
if (ctx .hasPlayer () && arg != null ) {
106
106
try {
107
107
int slot = Integer .parseInt (arg );
@@ -123,7 +123,7 @@ public static void register() {
123
123
}
124
124
});
125
125
126
- Placeholders .register (new Identifier ("player" , "inventory_slot_no_rarity" ), (ctx , arg ) -> {
126
+ Placeholders .register (Identifier . of ("player" , "inventory_slot_no_rarity" ), (ctx , arg ) -> {
127
127
if (ctx .hasPlayer () && arg != null ) {
128
128
try {
129
129
int slot = Integer .parseInt (arg );
@@ -145,7 +145,7 @@ public static void register() {
145
145
}
146
146
});
147
147
148
- Placeholders .register (new Identifier ("player" , "equipment_slot" ), (ctx , arg ) -> {
148
+ Placeholders .register (Identifier . of ("player" , "equipment_slot" ), (ctx , arg ) -> {
149
149
if (ctx .hasPlayer () && arg != null ) {
150
150
try {
151
151
var slot = EquipmentSlot .byName (arg );
@@ -161,7 +161,7 @@ public static void register() {
161
161
}
162
162
});
163
163
164
- Placeholders .register (new Identifier ("player" , "equipment_slot_no_rarity" ), (ctx , arg ) -> {
164
+ Placeholders .register (Identifier . of ("player" , "equipment_slot_no_rarity" ), (ctx , arg ) -> {
165
165
if (ctx .hasPlayer () && arg != null ) {
166
166
try {
167
167
var slot = EquipmentSlot .byName (arg );
@@ -177,7 +177,7 @@ public static void register() {
177
177
}
178
178
});
179
179
180
- Placeholders .register (new Identifier ("player" , "playtime" ), (ctx , arg ) -> {
180
+ Placeholders .register (Identifier . of ("player" , "playtime" ), (ctx , arg ) -> {
181
181
if (ctx .hasPlayer ()) {
182
182
int x = ctx .player ().getStatHandler ().getStat (Stats .CUSTOM .getOrCreateStat (Stats .PLAY_TIME ));
183
183
return PlaceholderResult .value (arg != null
@@ -189,7 +189,7 @@ public static void register() {
189
189
}
190
190
});
191
191
192
- Placeholders .register (new Identifier ("player" , "statistic" ), (ctx , arg ) -> {
192
+ Placeholders .register (Identifier . of ("player" , "statistic" ), (ctx , arg ) -> {
193
193
if (ctx .hasPlayer () && arg != null ) {
194
194
try {
195
195
var args = arg .split (" " );
@@ -226,7 +226,7 @@ public static void register() {
226
226
}
227
227
});
228
228
229
- Placeholders .register (new Identifier ("player" , "statistic_raw" ), (ctx , arg ) -> {
229
+ Placeholders .register (Identifier . of ("player" , "statistic_raw" ), (ctx , arg ) -> {
230
230
if (ctx .hasPlayer () && arg != null ) {
231
231
try {
232
232
var args = arg .split (" " );
@@ -263,7 +263,7 @@ public static void register() {
263
263
}
264
264
});
265
265
266
- Placeholders .register (new Identifier ("player" , "objective" ), (ctx , arg ) -> {
266
+ Placeholders .register (Identifier . of ("player" , "objective" ), (ctx , arg ) -> {
267
267
if (ctx .hasPlayer () && arg != null ) {
268
268
try {
269
269
ServerScoreboard scoreboard = ctx .server ().getScoreboard ();
@@ -282,7 +282,7 @@ public static void register() {
282
282
}
283
283
});
284
284
285
- Placeholders .register (new Identifier ("player" , "pos_x" ), (ctx , arg ) -> {
285
+ Placeholders .register (Identifier . of ("player" , "pos_x" ), (ctx , arg ) -> {
286
286
if (ctx .hasPlayer ()) {
287
287
double value = ctx .player ().getX ();
288
288
String format = "%.2f" ;
@@ -302,7 +302,7 @@ public static void register() {
302
302
}
303
303
});
304
304
305
- Placeholders .register (new Identifier ("player" , "pos_y" ), (ctx , arg ) -> {
305
+ Placeholders .register (Identifier . of ("player" , "pos_y" ), (ctx , arg ) -> {
306
306
if (ctx .hasPlayer ()) {
307
307
double value = ctx .player ().getY ();
308
308
String format = "%.2f" ;
@@ -322,7 +322,7 @@ public static void register() {
322
322
}
323
323
});
324
324
325
- Placeholders .register (new Identifier ("player" , "pos_z" ), (ctx , arg ) -> {
325
+ Placeholders .register (Identifier . of ("player" , "pos_z" ), (ctx , arg ) -> {
326
326
if (ctx .hasPlayer ()) {
327
327
double value = ctx .player ().getZ ();
328
328
String format = "%.2f" ;
@@ -342,7 +342,7 @@ public static void register() {
342
342
}
343
343
});
344
344
345
- Placeholders .register (new Identifier ("player" , "uuid" ), (ctx , arg ) -> {
345
+ Placeholders .register (Identifier . of ("player" , "uuid" ), (ctx , arg ) -> {
346
346
if (ctx .hasPlayer ()) {
347
347
return PlaceholderResult .value (ctx .player ().getUuidAsString ());
348
348
} else if (ctx .hasGameProfile ()) {
@@ -352,39 +352,39 @@ public static void register() {
352
352
}
353
353
});
354
354
355
- Placeholders .register (new Identifier ("player" , "health" ), (ctx , arg ) -> {
355
+ Placeholders .register (Identifier . of ("player" , "health" ), (ctx , arg ) -> {
356
356
if (ctx .hasPlayer ()) {
357
357
return PlaceholderResult .value (String .format ("%.0f" , ctx .player ().getHealth ()));
358
358
} else {
359
359
return PlaceholderResult .invalid ("No player!" );
360
360
}
361
361
});
362
362
363
- Placeholders .register (new Identifier ("player" , "max_health" ), (ctx , arg ) -> {
363
+ Placeholders .register (Identifier . of ("player" , "max_health" ), (ctx , arg ) -> {
364
364
if (ctx .hasPlayer ()) {
365
365
return PlaceholderResult .value (String .format ("%.0f" , ctx .player ().getMaxHealth ()));
366
366
} else {
367
367
return PlaceholderResult .invalid ("No player!" );
368
368
}
369
369
});
370
370
371
- Placeholders .register (new Identifier ("player" , "hunger" ), (ctx , arg ) -> {
371
+ Placeholders .register (Identifier . of ("player" , "hunger" ), (ctx , arg ) -> {
372
372
if (ctx .hasPlayer ()) {
373
373
return PlaceholderResult .value (String .valueOf (ctx .player ().getHungerManager ().getFoodLevel ()));
374
374
} else {
375
375
return PlaceholderResult .invalid ("No player!" );
376
376
}
377
377
});
378
378
379
- Placeholders .register (new Identifier ("player" , "saturation" ), (ctx , arg ) -> {
379
+ Placeholders .register (Identifier . of ("player" , "saturation" ), (ctx , arg ) -> {
380
380
if (ctx .hasPlayer ()) {
381
381
return PlaceholderResult .value (String .format ("%.0f" , ctx .player ().getHungerManager ().getSaturationLevel ()));
382
382
} else {
383
383
return PlaceholderResult .invalid ("No player!" );
384
384
}
385
385
});
386
386
387
- Placeholders .register (new Identifier ("player" , "team_name" ), (ctx , arg ) -> {
387
+ Placeholders .register (Identifier . of ("player" , "team_name" ), (ctx , arg ) -> {
388
388
if (ctx .hasPlayer ()) {
389
389
var team = ctx .player ().getScoreboardTeam ();
390
390
return PlaceholderResult .value (team ==null ? Text .empty () : Text .of (team .getName ()));
@@ -393,7 +393,7 @@ public static void register() {
393
393
}
394
394
});
395
395
396
- Placeholders .register (new Identifier ("player" , "team_displayname" ), (ctx , arg ) -> {
396
+ Placeholders .register (Identifier . of ("player" , "team_displayname" ), (ctx , arg ) -> {
397
397
if (ctx .hasPlayer ()) {
398
398
var team = (Team ) ctx .player ().getScoreboardTeam ();
399
399
return PlaceholderResult .value (team ==null ? Text .empty () : team .getDisplayName ());
@@ -402,7 +402,7 @@ public static void register() {
402
402
}
403
403
});
404
404
405
- Placeholders .register (new Identifier ("player" , "team_displayname_formatted" ), (ctx , arg ) -> {
405
+ Placeholders .register (Identifier . of ("player" , "team_displayname_formatted" ), (ctx , arg ) -> {
406
406
if (ctx .hasPlayer ()) {
407
407
var team = (Team ) ctx .player ().getScoreboardTeam ();
408
408
return PlaceholderResult .value (team ==null ? Text .empty () : team .getFormattedName ());
0 commit comments