Skip to content

Commit d81c222

Browse files
committed
UpdateManager encoding fixes
1 parent ff6a1cf commit d81c222

1 file changed

Lines changed: 61 additions & 57 deletions

File tree

src/main/java/me/leoko/advancedban/manager/UpdateManager.java

Lines changed: 61 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,64 @@ public static UpdateManager get() {
3434
public void setup() {
3535
MethodInterface mi = Universal.get().getMethods();
3636

37-
if(mi.isUnitTesting()) return;
37+
if (mi.isUnitTesting()) return;
38+
39+
if (!mi.contains(mi.getMessages(), "UnNote.Usage")) {
40+
try {
41+
addMessage("Check:", " Note: \"&cNotes &8» &7%COUNT%\"", 1);
42+
FileUtils.writeLines(new File(mi.getDataFolder(), "Messages.yml"), "UTF8", Arrays.asList(
43+
"",
44+
"# Automatically added by v2.2.1 update process",
45+
"UnNote:",
46+
" Usage: \"&cUsage &8» &7&o/unwarn [ID] or /unnote clear [Name]\"",
47+
" NotFound: \"&cCould not find note #%ID%\"",
48+
" Done: \"&7Note &a&o#%ID% &7was successfully deleted!\"",
49+
" Notification: \"&e&o%OPERATOR% &7unnoted &c&o%NAME%\"",
50+
" Clear:",
51+
" Empty:\"&c&o%NAME% &7has no notes!\"",
52+
" Done:\"&7Cleared &a&o%COUNT% &7notes\"",
53+
"",
54+
"Note:",
55+
" Usage: \"&cUsage &8» &7&o/note [Name] [Reason]\"",
56+
" Done: \"&c&o%NAME% &7was successfully noted!\"",
57+
" Exempt: \"&7You are not able to note &c&o%NAME%\"",
58+
" Notification:",
59+
" - \"&c&o%NAME% &7got noted by &e&o%OPERATOR%\"",
60+
" - \"&7For the reason &o%REASON%\"",
61+
"",
62+
"Notes:",
63+
" Usage: \"&cUsage &8» &7&o/notes [Name] <Page> &cor &7&o/notes <Page>\"",
64+
" OutOfIndex: \"&cThere is no page %PAGE%!\"",
65+
" NoEntries: \"&c&o%NAME% has no notes yet\"",
66+
" Header:",
67+
" - \"&7\"",
68+
" - \"%PREFIX% &7Notes for %NAME%:\"",
69+
" - \"&7\"",
70+
" Entry:",
71+
" - \"&7%DATE% &8| &7By &o%OPERATOR% &7(&c#%ID%&7)\"",
72+
" - \"&8> &e%REASON%\"",
73+
" - \"&7\"",
74+
" Footer: \"&7Page &e&o%CURRENT_PAGE% &7of &e&o%TOTAL_PAGES% &8| &7Notes: &e&o%COUNT%\"",
75+
" PageFooter: \"&7Use &e&o/notes %NAME% %NEXT_PAGE% &7to see the next page\"",
76+
"",
77+
"NotesOwn:",
78+
" OutOfIndex: \"&cThere is no page %PAGE%!\"",
79+
" NoEntries: \"&c&oYou have no notes yet\"",
80+
" Header:",
81+
" - \"&7\"",
82+
" - \"%PREFIX% &7Your notes:\"",
83+
" - \"&7\"",
84+
" Entry:",
85+
" - \"&7%DATE% &8| &7By &o%OPERATOR% &7(&c#%ID%&7)\"",
86+
" - \"&8> &e%REASON%\"",
87+
" - \"&7\"",
88+
" Footer: \"&7Page &e&o%CURRENT_PAGE% &7of &e&o%TOTAL_PAGES% &8| &7Notes: &e&o%COUNT%\"",
89+
" PageFooter: \"&7Use &e&o/notes %NEXT_PAGE% &7to see the next page\""
90+
), true);
91+
} catch (IOException e) {
92+
e.printStackTrace();
93+
}
94+
}
3895

3996
if (!mi.contains(mi.getMessages(), "WarnsOwn")) {
4097
addMessage("ChangeReason:", "", 0);
@@ -60,60 +117,7 @@ public void setup() {
60117
addMessage("UnMute:", " Notification: \"&e&o%OPERATOR% &7unmuted &c&o%NAME%\"", 1);
61118
addMessage("UnWarn:", " Notification: \"&e&o%OPERATOR% &7unwarned &c&o%NAME%\"", 1);
62119
}
63-
64-
if (!mi.contains(mi.getMessages(), "UnNote.Usage")) { try {
65-
FileUtils.writeLines(new File(mi.getDataFolder(), "Messages.yml"), Arrays.asList(
66-
"UnNote:",
67-
" Usage: \"&cUsage &8» &7&o/unwarn [ID] or /unnote clear [Name]\"",
68-
" NotFound: \"&cCould not find note #%ID%\"",
69-
" Done: \"&7Note &a&o#%ID% &7was successfully deleted!\"",
70-
" Notification: \"&e&o%OPERATOR% &7unnoted &c&o%NAME%\"",
71-
" Clear:",
72-
" Empty:\"&c&o%NAME% &7has no notes!\"",
73-
" Done:\"&7Cleared &a&o%COUNT% &7notes\"",
74-
"",
75-
"Note:",
76-
" Usage: \"&cUsage &8» &7&o/note [Name] [Reason]\"",
77-
" Done: \"&c&o%NAME% &7was successfully noted!\"",
78-
" Exempt: \"&7You are not able to note &c&o%NAME%\"",
79-
" Notification:",
80-
" - \"&c&o%NAME% &7got noted by &e&o%OPERATOR%\"",
81-
" - \"&7For the reason &o%REASON%\"",
82-
"",
83-
"Notes:",
84-
" Usage: \"&cUsage &8» &7&o/notes [Name] <Page> &cor &7&o/notes <Page>\"",
85-
" OutOfIndex: \"&cThere is no page %PAGE%!\"",
86-
" NoEntries: \"&c&o%NAME% has no notes yet\"",
87-
" Header:",
88-
" - \"&7\"",
89-
" - \"%PREFIX% &7Notes for %NAME%:\"",
90-
" - \"&7\"",
91-
" Entry:",
92-
" - \"&7%DATE% &8| &7By &o%OPERATOR% &7(&c#%ID%&7)\"",
93-
" - \"&8> &e%REASON%\"",
94-
" - \"&7\"",
95-
" Footer: \"&7Page &e&o%CURRENT_PAGE% &7of &e&o%TOTAL_PAGES% &8| &7Notes: &e&o%COUNT%\"",
96-
" PageFooter: \"&7Use &e&o/notes %NAME% %NEXT_PAGE% &7to see the next page\"",
97-
"",
98-
"NotesOwn:",
99-
" OutOfIndex: \"&cThere is no page %PAGE%!\"",
100-
" NoEntries: \"&c&oYou have no notes yet\"",
101-
" Header:",
102-
" - \"&7\"",
103-
" - \"%PREFIX% &7Your notes:\"",
104-
" - \"&7\"",
105-
" Entry:",
106-
" - \"&7%DATE% &8| &7By &o%OPERATOR% &7(&c#%ID%&7)\"",
107-
" - \"&8> &e%REASON%\"",
108-
" - \"&7\"",
109-
" Footer: \"&7Page &e&o%CURRENT_PAGE% &7of &e&o%TOTAL_PAGES% &8| &7Notes: &e&o%COUNT%\"",
110-
" PageFooter: \"&7Use &e&o/notes %NEXT_PAGE% &7to see the next page\""
111-
), true);
112-
} catch (IOException e) {
113-
e.printStackTrace();
114-
}
115-
}
116-
120+
117121
if (!mi.contains(mi.getMessages(), "Check.MuteReason")) {
118122
try {
119123
File file = new File(mi.getDataFolder(), "Messages.yml");
@@ -236,10 +240,10 @@ public void setup() {
236240
private void addMessage(String search, String insert, int indexOffset) {
237241
try {
238242
File file = new File(Universal.get().getMethods().getDataFolder(), "Messages.yml");
239-
List<String> lines = FileUtils.readLines(file, Charset.defaultCharset());
243+
List<String> lines = FileUtils.readLines(file, "UTF8");
240244
int index = lines.indexOf(search);
241245
lines.add(index + indexOffset, insert);
242-
FileUtils.writeLines(file, lines);
246+
FileUtils.writeLines(file, "UTF8", lines);
243247
} catch (IOException ex) {
244248
ex.printStackTrace();
245249
}

0 commit comments

Comments
 (0)