Skip to content

Commit b70694d

Browse files
committed
format
1 parent 7e1c4f2 commit b70694d

File tree

1 file changed

+15
-33
lines changed

1 file changed

+15
-33
lines changed

addon/discount/src/main/java/com/ghostchu/quickshop/addon/discount/command/DiscountCommand.java

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ private void list(CommandSender sender, String[] passThroughArgs) {
6363
ChatSheetPrinter printer = new ChatSheetPrinter(sender);
6464
printer.printHeader();
6565
printer.printLine(quickshop.text().of(sender, "addon.discount.discount-code-list").forLocale());
66-
main.getCodeManager().getCodes().stream().filter(code -> code.getOwner().equals(((Player) sender).getUniqueId()))
67-
.forEach(code -> printer.printLine(Component.text(code.getCode()).color(NamedTextColor.AQUA)));
66+
main.getCodeManager().getCodes().stream().filter(code -> code.getOwner().equals(((Player) sender).getUniqueId())).forEach(code -> printer.printLine(Component.text(code.getCode()).color(NamedTextColor.AQUA)));
6867
printer.printFooter();
6968
}
7069

@@ -181,8 +180,7 @@ private void info(CommandSender sender, String[] passThroughArgs) {
181180
}
182181
String name = "Unknown";
183182
Profile profile = quickshop.getPlayerFinder().find(code.getOwner());
184-
if (profile != null && !profile.getName().isEmpty())
185-
name = profile.getName();
183+
if (profile != null && !profile.getName().isEmpty()) name = profile.getName();
186184
Component appliedTo = quickshop.text().of(sender, "addon.discount.code-type." + code.getCodeType().name()).forLocale();
187185
String remainsUsage;
188186
int remains = code.getRemainsUsage(((Player) sender).getUniqueId());
@@ -191,9 +189,7 @@ private void info(CommandSender sender, String[] passThroughArgs) {
191189
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
192190
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
193191
String expiredOn = sdf.format(new Date(code.getExpiredTime()));
194-
quickshop.text().of(sender, "addon.discount.discount-code-details"
195-
, code.getCode(), name, appliedTo, remainsUsage, expiredOn, code.getThreshold(),
196-
code.getRate().format(sender, quickshop.text())).send();
192+
quickshop.text().of(sender, "addon.discount.discount-code-details", code.getCode(), name, appliedTo, remainsUsage, expiredOn, code.getThreshold(), code.getRate().format(sender, quickshop.text())).send();
197193
}
198194

199195

@@ -262,11 +258,11 @@ private void create(CommandSender sender, String[] passThroughArgs) {
262258
quickshop.text().of(sender, "addon.discount.invalid-threshold-restriction").send();
263259
case INVALID_EXPIRE_TIME -> quickshop.text().of(sender, "addon.discount.invalid-expire-time").send();
264260
case CODE_EXISTS -> quickshop.text().of(sender, "addon.discount.discount-code-already-exists").send();
265-
case SUCCESS -> quickshop.text().of(sender, "addon.discount.discount-code-created"
266-
, code
267-
, CommonUtil.prettifyText(codeType.name())
268-
, "/qs discount install " + code,
269-
"/qs discount addshop").send();
261+
case SUCCESS -> quickshop.text().of(sender, "addon.discount.discount-code-created",
262+
code,
263+
CommonUtil.prettifyText(codeType.name()),
264+
"/qs discount install " + code,
265+
"/qs discount config " + code + " addshop").send();
270266
}
271267
}
272268

@@ -310,8 +306,7 @@ private void remove(CommandSender sender, String[] passThroughArgs) {
310306
return;
311307
}
312308
if (sender instanceof Player p) {
313-
if (!code.getOwner().equals(p.getUniqueId()) &&
314-
!quickshop.perm().hasPermission(sender, "quickshopaddon.discount.remove.bypass")) {
309+
if (!code.getOwner().equals(p.getUniqueId()) && !quickshop.perm().hasPermission(sender, "quickshopaddon.discount.remove.bypass")) {
315310
quickshop.text().of(sender, "no-permission").send();
316311
return;
317312
}
@@ -354,12 +349,8 @@ private void remove(CommandSender sender, String[] passThroughArgs) {
354349
}
355350
if (cmdArg.length == 4) {
356351
return switch (cmdArg[0]) {
357-
case "create" -> List.of(
358-
"1. Command Hint:",
359-
"2. Argument: <rate>",
360-
"3. Description: The actual percentage or money you will earn",
361-
"4. Input `30%` = price * 0.3",
362-
"5. Input `50` = price-50");
352+
case "create" ->
353+
List.of("1. Command Hint:", "2. Argument: <rate>", "3. Description: The actual percentage or money you will earn", "4. Input `30%` = price * 0.3", "5. Input `50` = price-50");
363354
default -> Collections.emptyList();
364355
};
365356
}
@@ -371,24 +362,15 @@ private void remove(CommandSender sender, String[] passThroughArgs) {
371362
}
372363
if (cmdArg.length == 6) {
373364
return switch (cmdArg[0]) {
374-
case "create" -> List.of(
375-
"1. Command Hint:",
376-
"2. Argument: [threshold]",
377-
"3. Description: min price to apply discount",
378-
"4. -1 for unlimited usage");
365+
case "create" ->
366+
List.of("1. Command Hint:", "2. Argument: [threshold]", "3. Description: min price to apply discount", "4. -1 for unlimited usage");
379367
default -> Collections.emptyList();
380368
};
381369
}
382370
if (cmdArg.length == 7) {
383371
return switch (cmdArg[0]) {
384-
case "create" -> List.of(
385-
"1. Command Hint:",
386-
"2. Argument: [expired]",
387-
"3. Description: The discount code expired time.",
388-
"4. -1 for unlimited duration.",
389-
"5. Accept both Zulu time and UNIX timestamp in seconds.",
390-
"6. Zulu Example: 2022-12-17T10:31:37Z",
391-
"7. UNIX Example: 1671273097");
372+
case "create" ->
373+
List.of("1. Command Hint:", "2. Argument: [expired]", "3. Description: The discount code expired time.", "4. -1 for unlimited duration.", "5. Accept both Zulu time and UNIX timestamp in seconds.", "6. Zulu Example: 2022-12-17T10:31:37Z", "7. UNIX Example: 1671273097");
392374
default -> Collections.emptyList();
393375
};
394376
}

0 commit comments

Comments
 (0)