Fixed commas breaking notes.

This commit is contained in:
Paul Reilly 2023-03-27 21:02:30 -05:00
parent 922a2bcc76
commit 1e97273e01

View File

@ -47,34 +47,34 @@ public class Command_notes extends FreedomCommand
switch (args[1]) switch (args[1])
{ {
case "list": case "list" ->
{ {
msgNew("<green>Player notes for <player>:", Placeholder.unparsed("player", playerData.getName())); msgNew("<green>Player notes for <player>:", Placeholder.unparsed("player", playerData.getName()));
int id = 1; int id = 1;
for (String note : playerData.getNotes()) for (String note : playerData.getNotes())
{ {
String a = note.replace("\\u002C", ",");
msgNew("<num>. <note>", msgNew("<num>. <note>",
Placeholder.unparsed("num", String.valueOf(id)), Placeholder.unparsed("num", String.valueOf(id)),
Placeholder.unparsed("note", note)); Placeholder.unparsed("note", a));
id++; id++;
} }
return true; return true;
} }
case "add" ->
case "add":
{ {
if (args.length < 3) if (args.length < 3)
{ {
return false; return false;
} }
String note = sender.getName() + ": " + StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " "); String note = sender.getName() + ": " + StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ")
.replace(",", "\\u002C");
playerData.addNote(note); playerData.addNote(note);
plugin.pl.save(playerData); plugin.pl.save(playerData);
msgNew("<green>Note added."); msgNew("<green>Note added.");
return true; return true;
} }
case "remove" ->
case "remove":
{ {
if (args.length < 3) if (args.length < 3)
{ {
@ -85,8 +85,7 @@ public class Command_notes extends FreedomCommand
try try
{ {
id = Integer.parseInt(args[2]); id = Integer.parseInt(args[2]);
} } catch (NumberFormatException e)
catch (NumberFormatException e)
{ {
msgNew("<red>Invalid number: <num>", Placeholder.unparsed("num", args[2])); msgNew("<red>Invalid number: <num>", Placeholder.unparsed("num", args[2]));
return true; return true;
@ -98,16 +97,14 @@ public class Command_notes extends FreedomCommand
{ {
plugin.pl.save(playerData); plugin.pl.save(playerData);
msgNew("<green>Note removed."); msgNew("<green>Note removed.");
} } else
else
{ {
msgNew("<red>No note with the ID of <id> exists.", Placeholder.unparsed("id", args[2])); msgNew("<red>No note with the ID of <id> exists.", Placeholder.unparsed("id", args[2]));
} }
return true; return true;
} }
case "clear" ->
case "clear":
{ {
int count = playerData.getNotes().size(); int count = playerData.getNotes().size();
playerData.clearNotes(); playerData.clearNotes();
@ -115,8 +112,7 @@ public class Command_notes extends FreedomCommand
msgNew("<green>Cleared <count> notes.", Placeholder.unparsed("count", String.valueOf(count))); msgNew("<green>Cleared <count> notes.", Placeholder.unparsed("count", String.valueOf(count)));
return true; return true;
} }
default ->
default:
{ {
return false; return false;
} }